Skip to content

feat/generate projects #1968

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion docs/ce/howto/using-terragrunt.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@ since this way may be deprecated in the future

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

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:
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:




```
generate_projects:
Expand Down Expand Up @@ -66,3 +69,17 @@ jobs:
setup-terragrunt: true
terragrunt-version: 0.44.1
```

### Note regarding SOPS

Since currently the generation happens in the backend where no access to SOPS variables exist this means
that if you use sops_decrypt_file in your terragrunt.hcl it will lead to an exception of sops decryption failed.
Current workaround is to use environment variable `DIGGER_GENERATE_PROJECT` and check if its true as follows:

```
locals {
secrets = get_env("DIGGER_GENERATE_PROJECT", "false") == "true" ? {} : yamldecode(sops_decrypt_file("secrets.yaml"))
}
```

This will ensure that an exception doesn't occur during generation in the backend.
2 changes: 2 additions & 0 deletions libs/digger_config/digger_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,8 @@ func checkBlockInChangedFiles(dir string, changedFiles []string) bool {
}

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