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

narrow-dinner-45042

12/18/2023, 4:04 PM
hello, Id like some help writing a config file template to match my directory structure. The terraform directories in my repo exist at many sublevels all within a single
terraform
directory, and if possible Id like to just wildcard match all subdirectories within
terraform/
. Example structure:
Copy code
|--terraform
|  |--top_level
|  |  |--<http://main.tf|main.tf>
|  |--subdirs
|  |  |--subdir1
|  |  |  |--<http://main.tf|main.tf>
|  |  |--subdir2
|  |  |  |--<http://main.tf|main.tf>
|  |--more_subdirs
|  |  |--subdir3
|  |  |  |--subdir4
|  |  |  |  |--<http://main.tf|main.tf>  
|--infracost.yml.tmpl
Is something like this possible? Ideally I dont want to have to separately configure every level of subdirectory. I just want infracost to run on every dir within
terraform/
l

little-author-61621

12/18/2023, 4:09 PM
@narrow-dinner-45042 something like this might work:
Copy code
version: 0.1
projects:
{{- range $project := matchPaths "terraform/:name(.*)/main.tf" }}
  - path: {{ $project._dir }}
    name: {{ $project.name }}
{{- end }}
n

narrow-dinner-45042

12/18/2023, 4:10 PM
ooo, thanks! Ill try it out
l

little-author-61621

12/18/2023, 4:10 PM
let me know if it works
n

narrow-dinner-45042

12/18/2023, 4:18 PM
that appears to work!
thank you
l

little-author-61621

12/18/2023, 4:18 PM
No worries!
n

narrow-dinner-45042

12/19/2023, 4:42 PM
hi @little-author-61621, following up on this thread. I added an
infracost.yml.tmpl
to the root of my repo and integrated infracost with the repo, but I am seeing infracost still running checks on PRs that dont touch any paths in my config file. Is this expected? Do these runs count against the 1000 runs/mo even if they detect no terraform changes?
l

little-author-61621

12/19/2023, 5:49 PM
If you have the
Only post a comment in pull requests that have Terraform changes (default)
setting turned on then any run that has no tf changes won’t be counted. Otherwise all runs are counted even if the paths aren’t specified in the config file because Infracost still runs to parse and check the config file paths.
n

narrow-dinner-45042

12/19/2023, 6:23 PM
got it, thanks!
2 Views