Skip to content

Commit f2e3f8d

Browse files
feat/generate projects (#1968)
* set flag * documenting the use of env variable * Update docs/ce/howto/using-terragrunt.mdx Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com> --------- Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
1 parent 03bd16b commit f2e3f8d

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

docs/ce/howto/using-terragrunt.mdx

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,10 @@ since this way may be deprecated in the future
3131

3232
[Demo repo](https://github.com/diggerhq/test-terragrunt-racecondition)
3333

34-
In many cases with terragrunt you don't want to mention all of your terragrunt components since there can be tens or hundreds of those (not to mention all the dependencies of those). In this case you can just leave it to digger and it will perform dynamic generation of projects for you before triggering the relevant `terragrunt apply` commands on all impacated projects per pull request. It will also handle dependencies of these projects. You can configure this using the following:
34+
In many cases with terragrunt you don't want to mention all of your terragrunt components since there can be tens or hundreds of those (not to mention all the dependencies of those). In this case you can just leave it to digger and it will perform dynamic generation of projects for you before triggering the relevant `terragrunt apply` commands on all impacted projects per pull request. It will also handle dependencies of these projects. You can configure this using the following:
35+
36+
37+
3538

3639
```
3740
generate_projects:
@@ -66,3 +69,17 @@ jobs:
6669
setup-terragrunt: true
6770
terragrunt-version: 0.44.1
6871
```
72+
73+
### Note regarding SOPS
74+
75+
Since currently the generation happens in the backend where no access to SOPS variables exist this means
76+
that if you use sops_decrypt_file in your terragrunt.hcl it will lead to an exception of sops decryption failed.
77+
Current workaround is to use environment variable `DIGGER_GENERATE_PROJECT` and check if its true as follows:
78+
79+
```
80+
locals {
81+
secrets = get_env("DIGGER_GENERATE_PROJECT", "false") == "true" ? {} : yamldecode(sops_decrypt_file("secrets.yaml"))
82+
}
83+
```
84+
85+
This will ensure that an exception doesn't occur during generation in the backend.

libs/digger_config/digger_config.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,8 @@ func checkBlockInChangedFiles(dir string, changedFiles []string) bool {
322322
}
323323

324324
func HandleYamlProjectGeneration(config *DiggerConfigYaml, terraformDir string, changedFiles []string) error {
325+
os.Setenv("DIGGER_GENERATE_PROJECT", "true")
326+
defer os.Unsetenv("DIGGER_GENERATE_PROJECT")
325327
if config.GenerateProjectsConfig != nil && config.GenerateProjectsConfig.TerragruntParsingConfig != nil {
326328
slog.Warn("terragrunt generation using top level config is deprecated",
327329
"recommendation", "https://docs.digger.dev/howto/generate-projects#blocks-syntax-with-terragrunt")

0 commit comments

Comments
 (0)