gruntwork-io / terragrunt

Terragrunt is a flexible orchestration tool that allows Infrastructure as Code written in OpenTofu/Terraform to scale.
https://terragrunt.gruntwork.io/
MIT License
8.07k stars 980 forks source link

[Dynamic configuration] - manage hundreds of accounts #2902

Closed ozbillwang closed 9 months ago

ozbillwang commented 9 months ago

Describe the solution you'd like I need to catch up on the features available in Terragrunt.

Please let me know if a particular feature exists and provide guidance if possible

Describe alternatives you've considered Need manage hundreds of accounts,

├── aws
│   ├── _envcommon
│   │   ├── README.md
│   │   └── app-1.hcl # with default values
│   │   └── app-2.hcl # with default values
│   │   └── app-3.hcl # with default values
│   ├── modules
│   │   └── app-module-1
│   │       └── main.tf
│   │   └── app-module-2
│   │       └── main.tf
│   │   └── app-module-3
│   │       └── main.tf
│   ├── terragrunt.hcl
│   ├── account-1
│   │   ├── account.hcl
│   │   └── ap-southeast-2
│   │       ├── app-1
│   │       │   └── terragrunt.hcl
│   ├── account-2
│   │   ├── account.hcl
│   │   └── ap-southeast-2
│   │       ├── app-1
│   │       │   └── terragrunt.hcl
│   │       ├── app-2
│   │       │   └── terragrunt.hcl
│   ├── account-3
│   │   ├── account.hcl
│   │   └── ap-southeast-2
│   │       ├── app-2
│   │       │   └── terragrunt.hcl
│   │       ├── app-3
│   │       │   └── terragrunt.hcl
│   │       └── region.hcl
...

So in above sample, if I need manage 100 accounts, I need repeat the part of account-XXX hundred times.

# depends on the applications will be deployed to account xxx
│   ├── account-XXX
│   │   ├── account.hcl
│   │   └── ap-southeast-2
│   │       ├── app-1
│   │       │   └── terragrunt.hcl
│   │       ├── app-2
│   │       │   └── terragrunt.hcl
│   │       ├── app-3
│   │       │   └── terragrunt.hcl
│   │       └── region.hcl

The only differences between them are two files:

Additional context Design diagram

Untitled-2024-01-20-1555

yhakbar commented 9 months ago

Hey @ozbillwang ,

It sounds like you're looking to leverage find_in_parent_folders. That will let you build out the hierarchy of configurations, as the terragrunt.hcl files can include the account.hcl and region.hcl files found in parent folders.

If you are looking for a solution to minimize the work required to stamp out the terragrunt.hcl configurations that leverage those includes, you can look to utilize boilerplate to automate that process in a script.

ozbillwang commented 9 months ago

nice, seems boilerplate is similar to Jinja2 . I will take a try.

new design https://excalidraw.com/#json=wBm-ZxElGqj_cSWEwVdUd,DrqLMJqXmyy2Z7mZQfYvVw