https://infracost.io logo
#help
Title
# help
b

broad-zoo-34077

01/05/2024, 11:30 AM
This message was deleted.
l

little-author-61621

01/05/2024, 11:56 AM
Hi @early-article-57185, does adding the
terraform/
prefix to the path help? Something like this:
Copy code
version: 0.1
projects:
{{- range $project := matchPaths "terraform/my_org-:service/environments/:env" }}
  - path : terraform/my_org-{{ $project.service }}/manifests
    name : my_org-{{ $project.service }}/{{$project.env}}
    terraform_var_files:
      - ../environments/{{$project.env}}/environment.tfvars
{{- end }}
e

early-article-57185

01/05/2024, 12:28 PM
No, after adding terraform/ prefix getting same
Copy code
version: 0.1
projects:
{{- range $project := matchPaths "my_org-:service }}
  - path : ./my_org-{{ $project.service }}/manifests
{{- end }}
for this template file I'm getting infracost.yml like below
Copy code
version: 0.1
projects:
  - path : ./my_org-location-service/manifests
  - path : ./my_org-location-service/manifests
  - path : ./my_org-location-service\environments\dev/manifests
  - path : ./my_org-location-service\environments\dev\environment.tfvars/manifests
  - path : ./my_org-location-service\environments\qa/manifests
  - path : ./my_org-location-service\environments\qa\environment.tfvars/manifests
  - path : ./my_org-location-service\manifests/manifests
  - path : ./my_org-location-service\manifests\datafactory.tf/manifests
  - path : ./my_org-location-service\manifests\functionapp.tf/manifests
  - path : ./my_org-location-service\manifests\locals.tf/manifests
  - path : ./my_org-location-service\manifests\variables.tf/manifests
  - path : ./my_org-location-service\manifests\versions.tf/manifests
l

little-author-61621

01/05/2024, 12:29 PM
- path : ./my_org-{{ $project.service }}/manifests
->
- path : terraform/my_org-{{ $project.service }}/manifests
e

early-article-57185

01/05/2024, 12:37 PM
Copy code
version: 0.1
projects:
{{- range $project := matchPaths "terraform/my_org-:service/environments/:env" }}
  - path : terraform/my_org-{{ $project.service }}/manifests
    name : my_org-{{ $project.service }}/{{$project.env}}
    terraform_var_files:
      - ../environments/{{$project.env}}/environment.tfvars
{{- end }}
version: 0.1 projects: In matchPaths if i add anything after / (forward slash) It Is giving result as version: 0.1 projects:
l

little-author-61621

01/05/2024, 1:22 PM
@early-article-57185 are you running this on a Windows machine?
And can you paste the exact command you are running?
e

early-article-57185

01/05/2024, 1:40 PM
I'm running this in VS Code git bash infracost generate config --repo-path=. --template-path=infracost.yml.tmpl --out-file=infracost.yml
l

little-author-61621

01/05/2024, 1:43 PM
@early-article-57185 Does using blackslashes help:
Copy code
version: 0.1
projects:
{{- range $project := matchPaths "my_org-:service\environments\:env" }}
  - path : .\my_org-{{ $project.service }}\manifests
    name : my_org-{{ $project.service }}\{{$project.env}}
    terraform_var_files:
      - ..\environments\{{$project.env}}\environment.tfvars
{{- end }}
e

early-article-57185

01/05/2024, 1:46 PM
getting error $ infracost generate config --repo-path=. --template-path=infracost.yml.tmpl --out-file=infracost.yml 2024-01-05T191522+05:30 INF Enabled policies V2 2024-01-05T191522+05:30 INF Enabled tag policies Error: could not parse template path: infracost.yml.tmpl err: template: infracost.yml.tmpl3 invalid syntax
l

little-author-61621

01/05/2024, 1:51 PM
Out of interest does something like this work:
Copy code
version: 0.1
projects:
{{- range $project := matchPaths "my_org-:service\\environments\\:env" }}
  - path : my_org-{{ $project.service }}\manifests
{{- end }}
I’m not running on a Windows machine just now so can’t test it, but if this doesn’t work then we can dig in more.
e

early-article-57185

01/05/2024, 1:54 PM
It is giving same result version: 0.1 projects:
l

little-author-61621

01/05/2024, 2:00 PM
Okay thanks, let me take this to the team and see if we can test it out on a Windows machine. In the meantime you should be able to work around it by creating a static config file like so:
Copy code
version: 0.1
projects:
  - name: my_org-location-service/dev
    path: my_org-location-service\manifests
    terraform_var_files:
      - ..\environments\dev\environment.tfvars
  - name: my_org-location-service/qa
    path: my_org-location-service\manifests
    terraform_var_files:
      - ..\environments\qa\environment.tfvars
  ...
e

early-article-57185

01/05/2024, 2:03 PM
okay, Thank you @little-author-61621