white-airport-8778
1. Is there a smarter way to setup this config? I’m having issues managing the varied directory structures:
```version: 0.1
projects:
{{- range $project := matchPaths "app/env?/terraform.tf" }}
{{- if ne $project.app "modules" }}
- path: ./{{ $project._dir }}
{{- if ne $project.app "ami-upgrade" }}
terraform_var_files:
- ../inputs.auto.tfvars
{{- end }}
{{- end }}
{{- end }}
{{- range $project := matchPaths "app/env/:why/terraform.tf" }}
{{- if ne $project.app "modules" }}
- path: ./{{ $project._dir }}
{{- if ne $project.app "ami-upgrade" }}
terraform_var_files:
- ../../inputs.auto.tfvars
{{- end }}
{{- end }}```
{{- end }}@mysterious-teacher-68276 any ideas on this?
white-airport-8778
acceptable-kilobyte-27376
01/17/2024, 7:28 PMmysterious-teacher-68276
01/17/2024, 7:29 PMI think a clearer example of how to formulate an if statement for like pattern matching might help?Not sure I fully understand what your asking here?
acceptable-kilobyte-27376
01/17/2024, 7:30 PMversion: 0.1
projects:
{{- range $project := matchPaths ":app/:env?/terraform.tf" }}
{{- if ne $<http://project.app|project.app> "modules" }}
- path: ./{{ $project._dir }}
name: {{ $<http://project.app|project.app> }}-{{ $project.env }}
{{- if ne $<http://project.app|project.app> "ami-upgrade" }}
terraform_var_files:
- ../inputs.auto.tfvars
{{- end }}
{{- end }}
{{- end }}
{{- range $project := matchPaths ":app/:env/:why/terraform.tf" }}
{{- if ne $<http://project.app|project.app> "modules" }}
- path: ./{{ $project._dir }}
name: {{ $<http://project.app|project.app> }}-{{ $project.env }}-{{ $project.why }}
{{- if ne $<http://project.app|project.app> "ami-upgrade" }}
terraform_var_files:
- ../../inputs.auto.tfvars
{{- end }}
{{- end }}
{{- end }}
acceptable-kilobyte-27376
01/17/2024, 7:31 PMacceptable-kilobyte-27376
01/17/2024, 7:32 PMacceptable-kilobyte-27376
01/17/2024, 7:33 PMmysterious-teacher-68276
01/17/2024, 7:35 PMacceptable-kilobyte-27376
01/17/2024, 7:35 PMcurl -fsSL <https://raw.githubusercontent.com/infracost/infracost/master/scripts/install.sh> | sh
acceptable-kilobyte-27376
01/17/2024, 7:36 PM--template-path
?mysterious-teacher-68276
01/17/2024, 7:37 PMmysterious-teacher-68276
01/17/2024, 7:38 PMmysterious-teacher-68276
01/17/2024, 7:38 PMacceptable-kilobyte-27376
01/17/2024, 7:38 PMmysterious-teacher-68276
01/17/2024, 7:39 PMOkay.. That actually looks super right.💪 nice
mysterious-teacher-68276
01/17/2024, 7:42 PMFollow up from that.. If we set an account wide config file base how would we override a repo to use nothing instead?Hmm we’d have to write a config file with the special autodetect syntax (nots in the docs at the moment). We don’t have a way to specify “don’t use a config-file” at the moment as these new auto-detect improvements are very recent.
Or would the better path be to look at removing that altogether?Let me link up with @white-airport-8778 about this and we can discuss but this might be the best way. Are all of your repos in a semi consistent fashion? i.e. how you specify vars e.t.c?
acceptable-kilobyte-27376
01/17/2024, 7:42 PMmysterious-teacher-68276
01/17/2024, 7:43 PMacceptable-kilobyte-27376
01/17/2024, 7:45 PM.infrastructure
folder.
It looks like that doesn't get parsed by the autoconfig (I assume it ignores .folders).
Error: No valid Terraform files found at path
mysterious-teacher-68276
01/17/2024, 7:45 PMmysterious-teacher-68276
01/17/2024, 7:46 PMversion: 0.1
projects:
{{- range $mod := .DetectedRootModules }}
{{- range $project := $mod.Projects }}
- path: {{ $mod.Path }}
name: {{ $project.Name }}
terraform_var_files:
{{- range $varFile := $project.TerraformVarFiles }}
- {{ $varFile }}
{{- end }}
{{- end}}
{{- end }}
acceptable-kilobyte-27376
01/17/2024, 7:46 PMmysterious-teacher-68276
01/17/2024, 7:47 PMmysterious-teacher-68276
01/17/2024, 7:47 PMwhite-airport-8778
acceptable-kilobyte-27376
01/17/2024, 7:47 PMmysterious-teacher-68276
01/17/2024, 7:48 PMmysterious-teacher-68276
01/17/2024, 7:48 PM.infrastructure
acceptable-kilobyte-27376
01/17/2024, 7:48 PMacceptable-kilobyte-27376
01/17/2024, 7:49 PMmysterious-teacher-68276
01/17/2024, 7:50 PMacceptable-kilobyte-27376
01/17/2024, 7:51 PMacceptable-kilobyte-27376
01/17/2024, 9:44 PMversion: 0.1
projects:
{{- range $module := matchPaths ":module/resources/:env/:name.tfvars" }}
- path: ./{{ $module.module }}
name: {{ $module.env }}-{{ $module.module }}-{{ $module.name }}
include_all_paths: true
terraform_var_files:
- resources/{{ $module.env}}/{{ base $module._path }}
{{- end }}
{{- range $module := matchPaths ":module" }}
{{- if not (startsWith $module.module ".")}}
{{- if isDir $module.module }}
{{- if not (pathExists $module.module "resources") }}
- path: {{ $module.module }}
name: {{ $module.module }}
{{- end }}
{{- end }}
{{- end }}
{{- end}}
mysterious-teacher-68276
01/18/2024, 5:42 AM