big-pencil-62615
05/31/2023, 8:40 PMapplications/give-site/give-ep/cloudops/stage/api-gateway
workspace: default
but infracost does not find a valid terraform file. From what I can tell, it looks at the root of our repo CruGlobal/cru-terraform,
not the path from which Atlantis ran its plan. How do I set up the infracost.yml so that Infracots runs on the same path used by Atlantis and not from the root of the repo? I tried the following
version: 0.1
projects:
- path: .*
include_all_paths: true # include root and non-root modules
dependency_paths:
- *./terrafrom.tf
Thanks for your helpbusy-agent-35515
05/31/2023, 9:21 PM- path: applications/give-site/give-ep/cloudops/stage/api-gateway
? Are you using Infracost with the JSON plan or do you want it to parse your TF code?big-pencil-62615
06/01/2023, 12:03 AM|
├── app-name-1 (directoruy)
│ ├── <http://terraform.tf|terraform.tf>
| |——- <http://aws.tf|aws.tf> (file defining general app resources)
│ ├── staging (directory)
| | |—— <http://terraform.tf|terraform.tf>
| | |—— <http://aws.tf|aws.tf> (file defining environment-specific resources)
│ └── production (directory)
| |——-<http://terraform.tf|terraform.tf>
| |——- <http://aws.tf|aws.tf>
├── app-name-2 (directoruy)
│ ├── <http://terraform.tf|terraform.tf>
| |——- <http://aws.tf|aws.tf> (file defining general app resources)
│ ├── staging (directory)
| | |—— <http://terraform.tf|terraform.tf>
| | |—— <http://aws.tf|aws.tf> (file defining environment-specific resources)
│ └── production (directory)
| |——-<http://terraform.tf|terraform.tf>
| |——- <http://aws.tf|aws.tf>
├── other_infrastructure
It is a single repository — but not a mono repo. I’m starting to think that it might be best to integrate infracost into our Atlantis docker instance with a custom workflow might be best.busy-agent-35515
06/01/2023, 9:35 AMversion: 0.1
projects:
{{- range $project := matchPaths ":app/:env/terraform.tf" }}
- path: {{ $project._dir }}
name: {{ $<http://project.app|project.app> }}/{{ $project.env }}
dependency_paths:
- {{ $project._dir }}/../terraform.tf
{{- end }}
will generate a config file like
version: 0.1
projects:
- path: app-name-1/production
name: app-name-1/production
dependency_paths:
- app-name-1/production/../terraform.tf
- path: app-name-1/staging
name: app-name-1/staging
dependency_paths:
- app-name-1/staging/../terraform.tf
Can you try it? Save the template to infracost.yml.tmpl
and run infracost generate config --repo-path . --template-path infracost.yml.tmpl --out-file infracost.yml
I need to have infracost run for only the files that have been changed per pull request.Our example has two Infracost runs: 1. On target branch to get the baseline 2. On feature branch against the baseline to get the diff just for the PR As everything lives in one repo, I think it should be quick enough
big-pencil-62615
06/01/2023, 1:28 PMbusy-agent-35515
06/01/2023, 1:30 PMwhite-airport-8778
busy-agent-35515
06/01/2023, 8:02 PMwhite-airport-8778
big-pencil-62615
06/01/2023, 10:46 PMwhite-airport-8778