terragruntArchived
37 messages
Terragrunt discussions
Archive: https://archive.sweetops.com/terragrunt/
Maarten van der Hoefalmost 6 years ago
Is anyone using any kind of IDE with Terragrunt autocompletion on dependencies and inputs ? I'm curious.
Davidalmost 6 years ago
I wrote a blog about why I find prefer Terragrunt to just Terraform: https://transcend.io/blog/why-we-use-terragrunt
joshmyersalmost 6 years ago
@David Nice! Can I ask about what your Terragrunt on disk structure looks like?
Davidalmost 6 years ago
Sure thing! "on disk" as in what our file structure looks like?
joshmyersalmost 6 years ago
Yup
joshmyersalmost 6 years ago
terraform
├── coreeng
│ ├── account.hcl
│ └── global
│ ├── env.hcl
│ └── us-east-1
│ ├── atlantis
│ │ └── terragrunt.hcl
│ ├── ecr
│ │ └── terragrunt.hcl
│ └── region.hcl
├── globals.hcl
├── prod
│ ├── account.hcl
│ └── prod
│ ├── env.hcl
│ ├── eu-central-1
│ │ ├── account-service
│ │ │ └── terragrunt.hcl
│ │ ├── device-service
│ │ │ └── terragrunt.hcl
│ │ ├── graph-service
│ │ │ └── terragrunt.hcl
│ │ ├── idp-service
│ │ │ └── terragrunt.hcl
│ │ ├── profile-service
│ │ │ └── terragrunt.hcl
│ │ ├── region.hcl
│ │ └── resource-service
│ │ └── terragrunt.hcl
│ ├── eu-west-1
│ │ ├── account-service
│ │ │ └── terragrunt.hcl
│ │ ├── buckets
│ │ │ ├── main.tf
│ │ │ └── terragrunt.hcl
│ │ ├── compliance-service
│ │ │ └── terragrunt.hcl
│ │ ├── device-service
│ │ │ └── terragrunt.hcl
│ │ ├── graph-service
│ │ │ └── terragrunt.hcl
│ │ ├── idp-service
│ │ │ └── terragrunt.hcl
│ │ ├── profile-service
│ │ │ └── terragrunt.hcl
│ │ ├── region.hcl
│ │ └── resource-service
│ │ └── terragrunt.hcl
│ ├── us-east-1
│ │ ├── account-service
│ │ │ └── terragrunt.hcl
│ │ ├── buckets
│ │ │ ├── main.tf
│ │ │ ├── terragrunt.hcl
│ │ │ └── tfplan
│ │ ├── compliance-service
│ │ │ └── terragrunt.hcl
│ │ ├── device-service
│ │ │ └── terragrunt.hcl
│ │ ├── graph-service
│ │ │ └── terragrunt.hcl
│ │ ├── idp-service
│ │ │ └── terragrunt.hcl
│ │ ├── profile-service
│ │ │ └── terragrunt.hcl
│ │ ├── region.hcl
│ │ └── resource-service
│ │ └── terragrunt.hcl
│ └── us-west-2
│ ├── account-service
│ │ └── terragrunt.hcl
│ ├── device-service
│ │ └── terragrunt.hcl
│ ├── graph-service
│ │ └── terragrunt.hcl
│ ├── idp-service
│ │ └── terragrunt.hcl
│ ├── profile-service
│ │ └── terragrunt.hcl
│ ├── region.hcl
│ └── resource-service
│ └── terragrunt.hcl
├── terragrunt.hcl
└── test
├── account.hcl
├── dev
│ ├── account-service.hcl
│ ├── compliance-service.hcl
│ ├── device-service.hcl
│ ├── env.hcl
│ ├── eu-central-1
│ │ ├── account-service
│ │ │ └── terragrunt.hcl
│ │ ├── device-service
│ │ │ └── terragrunt.hcl
│ │ ├── graph-service
│ │ │ └── terragrunt.hcl
│ │ ├── idp-service
│ │ │ └── terragrunt.hcl
│ │ ├── profile-service
│ │ │ └── terragrunt.hcl
│ │ ├── region.hcl
│ │ └── resource-service
│ │ └── terragrunt.hcl
│ ├── eu-west-1
│ │ ├── account-service
│ │ │ └── terragrunt.hcl
│ │ ├── compliance-service
│ │ │ └── terragrunt.hcl
│ │ ├── device-service
│ │ │ └── terragrunt.hcl
│ │ ├── graph-service
│ │ │ └── terragrunt.hcl
│ │ ├── idp-service
│ │ │ └── terragrunt.hcl
│ │ ├── profile-service
│ │ │ └── terragrunt.hcl
│ │ ├── region.hcl
│ │ └── resource-service
│ │ └── terragrunt.hcl
│ ├── graph-service.hcl
│ ├── idp-service.hcl
│ ├── profile-service.hcl
│ ├── resource-service.hcl
│ ├── us-east-1
│ │ ├── account-service
│ │ │ └── terragrunt.hcl
│ │ ├── compliance-service
│ │ │ └── terragrunt.hcl
│ │ ├── device-service
│ │ │ └── terragrunt.hcl
│ │ ├── graph-service
│ │ │ └── terragrunt.hcl
│ │ ├── idp-service
│ │ │ └── terragrunt.hcl
│ │ ├── profile-service
│ │ │ └── terragrunt.hcl
│ │ ├── region.hcl
│ │ └── resource-service
│ │ └── terragrunt.hcl
│ └── us-west-2
│ ├── account-service
│ │ └── terragrunt.hcl
│ ├── device-service
│ │ └── terragrunt.hcl
│ ├── graph-service
│ │ └── terragrunt.hcl
│ ├── idp-service
│ │ └── terragrunt.hcl
│ ├── profile-service
│ │ └── terragrunt.hcl
│ ├── region.hcl
│ └── resource-service
│ └── terragrunt.hcl
└── qa
├── env.hcl
├── eu-central-1
│ ├── account-service
│ │ └── terragrunt.hcl
│ ├── device-service
│ │ └── terragrunt.hcl
│ ├── graph-service
│ │ └── terragrunt.hcl
│ ├── idp-service
│ │ └── terragrunt.hcl
│ ├── profile-service
│ │ └── terragrunt.hcl
│ ├── region.hcl
│ └── resource-service
│ └── terragrunt.hcl
├── eu-west-1
│ ├── account-service
│ │ └── terragrunt.hcl
│ ├── compliance-service
│ │ └── terragrunt.hcl
│ ├── device-service
│ │ └── terragrunt.hcl
│ ├── graph-service
│ │ └── terragrunt.hcl
│ ├── idp-service
│ │ └── terragrunt.hcl
│ ├── profile-service
│ │ └── terragrunt.hcl
│ ├── region.hcl
│ └── resource-service
│ └── terragrunt.hcl
├── us-east-1
│ ├── account-service
│ │ └── terragrunt.hcl
│ ├── compliance-service
│ │ └── terragrunt.hcl
│ ├── device-service
│ │ └── terragrunt.hcl
│ ├── graph-service
│ │ └── terragrunt.hcl
│ ├── idp-service
│ │ └── terragrunt.hcl
│ ├── profile-service
│ │ └── terragrunt.hcl
│ ├── region.hcl
│ └── resource-service
│ └── terragrunt.hcl
└── us-west-2
├── account-service
│ └── terragrunt.hcl
├── device-service
│ └── terragrunt.hcl
├── graph-service
│ └── terragrunt.hcl
├── idp-service
│ └── terragrunt.hcl
├── profile-service
│ └── terragrunt.hcl
├── region.hcl
└── resource-service
└── terragrunt.hcl
102 directories, 114 filesjoshmyersalmost 6 years ago
Sharing locals between terragrunt.hcl’s still isn’t a thing in TG AFAIK. There are a few interesting PRs/ideas how to DRY up this somewhat
joshmyersalmost 6 years ago
account>env>region>thing
joshmyersalmost 6 years ago
I suppose with Atlantis involved, DRY code isn’t necessarily what you want given triggers off an individual file
joshmyersalmost 6 years ago(edited)
Have you come up with any nice ways to layout your TG code while mainting Atlantis triggering on scoped events? convention over configuration?
Davidalmost 6 years ago
I believe you can share locals through
Here's a directory tree (with some DNS and other duplicated things removed) from one of our projects:
read_terragrunt_config, unless I'm misunderstanding what you're trying to share. And yep, we like lots and lots of small files because our Atlantis config generation is automated.Here's a directory tree (with some DNS and other duplicated things removed) from one of our projects:
Davidalmost 6 years ago(edited)
infra
├── README.md
├── admin
│ ├── common.block
│ ├── datadog
│ │ ├── env-dev
│ │ │ ├── secrets
│ │ │ │ └── terragrunt.hcl
│ │ │ └── terragrunt.hcl
│ │ └── provider.hcl
│ ├── organizations
│ │ ├── atlantis
│ │ │ └── terragrunt.hcl
│ │ ├── commons
│ │ │ └── terragrunt.hcl
│ │ ├── identity
│ │ │ └── terragrunt.hcl
│ │ ├── provider.block
│ │ ├── sandbox
│ │ │ └── terragrunt.hcl
│ │ ├── staging
│ │ │ └── terragrunt.hcl
│ │ ├── testing
│ │ │ └── terragrunt.hcl
│ │ └── transcend
│ │ ├── provider.block
│ │ └── terragrunt.hcl
│ ├── people.json
│ ├── policies
│ │ ├── admin.tf
│ │ ├── admin_no_user_iam.tf
│ │ ├── ci_policy.tf
│ │ └── terragrunt.hcl
│ ├── roles
│ │ ├── atlantis_org
│ │ │ ├── admin
│ │ │ │ └── terragrunt.hcl
│ │ │ └── atlantis
│ │ │ └── terragrunt.hcl
│ │ ├── commons_org
│ │ │ ├── atlantis
│ │ │ │ └── terragrunt.hcl
│ │ │ └── ecr_role
│ │ │ └── terragrunt.hcl
│ │ ├── identity_org
│ │ │ ├── access_admin_role
│ │ │ │ └── terragrunt.hcl
│ │ │ └── atlantis
│ │ │ └── terragrunt.hcl
│ │ ├── role_provider.block
│ │ ├── sandbox_org
│ │ │ ├── admin
│ │ │ │ └── terragrunt.hcl
│ │ │ ├── atlantis
│ │ │ │ └── terragrunt.hcl
│ │ │ └── ci
│ │ │ └── terragrunt.hcl
│ │ ├── staging_org
│ │ │ ├── admin
│ │ │ │ └── terragrunt.hcl
│ │ │ ├── atlantis
│ │ │ │ └── terragrunt.hcl
│ │ │ ├── ci
│ │ │ │ └── terragrunt.hcl
│ │ │ └── integrations_admin
│ │ │ └── terragrunt.hcl
│ │ ├── testing_org
│ │ │ ├── admin
│ │ │ │ └── terragrunt.hcl
│ │ │ └── atlantis
│ │ │ └── terragrunt.hcl
│ │ └── transcend_org
│ │ ├── admin
│ │ │ └── terragrunt.hcl
│ │ ├── admin_no_iam
│ │ │ └── terragrunt.hcl
│ │ ├── atlantis
│ │ │ └── terragrunt.hcl
│ │ ├── ci
│ │ │ └── terragrunt.hcl
│ │ ├── integrations_admin
│ │ │ └── terragrunt.hcl
│ │ └── role_provider.block
│ ├── terragrunt-config-admin.hcl
│ └── users
│ ├── datadog
│ └── identity_org
│ ├── access_key_management
│ │ └── terragrunt.hcl
│ ├── not_robots
│ │ └── terragrunt.hcl
│ └── robots
│ └── terragrunt.hcl
├── admin-dashboard
│ └── env-dev
│ └── terragrunt.hcl
├── atlantis
│ ├── ami
│ │ ├── README.md
│ │ ├── main.pkr.hcl
│ │ ├── terragroan.js
│ │ └── user_whitelist.js
│ ├── instance
│ │ └── terragrunt.hcl
│ └── secrets
│ └── terragrunt.hcl
├── backend
│ ├── README.md
│ ├── ecr
│ │ └── terragrunt.hcl
│ ├── env-dev
│ │ ├── alb
│ │ │ └── terragrunt.hcl
│ │ ├── buckets
│ │ │ └── terragrunt.hcl
│ │ ├── database
│ │ │ ├── primary
│ │ │ │ └── terragrunt.hcl
│ │ │ └── recovery
│ │ │ ├── kms_lookup
│ │ │ │ └── terragrunt.hcl
│ │ │ └── terragrunt.hcl
│ │ ├── ecs
│ │ │ ├── cluster
│ │ │ │ └── terragrunt.hcl
│ │ │ ├── common.hcl
│ │ │ ├── container
│ │ │ │ ├── secrets
│ │ │ │ │ └── terragrunt.hcl
│ │ │ │ └── terragrunt.hcl
│ │ │ ├── daemon_container
│ │ │ │ └── terragrunt.hcl
│ │ │ ├── daemon_service
│ │ │ │ └── terragrunt.hcl
│ │ │ ├── service
│ │ │ │ └── terragrunt.hcl
│ │ │ └── task_permissions
│ │ │ └── terragrunt.hcl
│ │ ├── security_groups
│ │ │ ├── alb
│ │ │ │ └── terragrunt.hcl
│ │ │ └── rds
│ │ │ ├── primary
│ │ │ │ └── terragrunt.hcl
│ │ │ └── recovery
│ │ │ └── terragrunt.hcl
│ │ ├── ses_forwarding
│ │ │ └── terragrunt.hcl
│ │ ├── ssm_bastion
│ │ │ └── terragrunt.hcl
│ │ └── vpc
│ │ ├── main
│ │ │ └── terragrunt.hcl
│ │ └── recovery
│ │ └── terragrunt.hcl
│ └── env-local
│ ├── comment_attachments_bucket
│ │ └── terragrunt.hcl
│ ├── communication_emails_bucket
│ │ └── terragrunt.hcl
│ ├── company_uploads_bucket
│ │ └── terragrunt.hcl
│ ├── dsr_assembly_bucket
│ │ └── terragrunt.hcl
│ └── ses_forwarding
│ └── terragrunt.hcl
├── cdn_transcend_io
│ └── env-dev
│ └── terragrunt.hcl
├── codelabs
│ ├── bower_deps_bucket
│ │ └── terragrunt.hcl
│ ├── env-dev
│ │ └── terragrunt.hcl
│ └── homepage_images
│ └── terragrunt.hcl
├── cognito
│ ├── README.md
│ └── user_group
│ └── env-dev
│ ├── secrets
│ │ └── terragrunt.hcl
│ └── terragrunt.hcl
├── common.tf
├── commons
│ └── s3_state
│ ├── main.tf
│ ├── terragrunt.hcl
│ └── vars.tf
├── constants
│ ├── README.md
│ ├── atlantis_org_id.tf
│ ├── commons_org_id.tf
│ ├── identity_org_id.tf
│ ├── prod_admin_no_iam_role_arn.tf
│ ├── prod_admin_role_arn.tf
│ ├── sandbox_admin_role_arn.tf
│ ├── sandbox_org_id.tf
│ ├── staging_admin_role_arn.tf
│ ├── staging_org_id.tf
│ ├── terragrunt.hcl
│ ├── testing_org_id.tf
│ └── transcend_org_id.tf
├── datadog
│ └── agent_container
│ └── env-dev
│ ├── secrets
│ │ └── terragrunt.hcl
│ └── terragrunt.hcl
├── externally_available_ecr
│ ├── ci-base
│ │ ├── Dockerfile
│ │ └── terragrunt.hcl
│ ├── ci-base-docker
│ │ ├── Dockerfile
│ │ └── terragrunt.hcl
│ ├── ci-base-go
│ │ ├── Dockerfile
│ │ └── terragrunt.hcl
│ ├── ci-base-pre-commit
│ │ ├── Dockerfile
│ │ └── terragrunt.hcl
│ ├── ci-base-puppeteer
│ │ ├── Dockerfile
│ │ └── terragrunt.hcl
│ └── sombra
│ └── terragrunt.hcl
├── firelens
│ └── container_definition
│ └── terragrunt.hcl
├── get_dot_env.sh
├── guardduty
│ ├── sandbox_org
│ │ ├── california
│ │ │ └── terragrunt.hcl
│ │ ├── frankfurt
│ │ │ └── terragrunt.hcl
│ │ ├── ireland
│ │ │ └── terragrunt.hcl
│ │ ├── ohio
│ │ │ └── terragrunt.hcl
│ │ └── virginia
│ │ └── terragrunt.hcl
│ ├── staging_org
│ │ ├── california
│ │ │ └── terragrunt.hcl
│ │ ├── frankfurt
│ │ │ └── terragrunt.hcl
│ │ ├── ireland
│ │ │ └── terragrunt.hcl
│ │ ├── ohio
│ │ │ └── terragrunt.hcl
│ │ └── virginia
│ │ └── terragrunt.hcl
│ └── transcend_org
│ ├── california
│ │ └── terragrunt.hcl
│ ├── frankfurt
│ │ └── terragrunt.hcl
│ ├── ireland
│ │ └── terragrunt.hcl
│ ├── ohio
│ │ └── terragrunt.hcl
│ └── virginia
│ └── terragrunt.hcl
├── homebrew
│ └── README.md
├── homepage
│ └── www_redirect
│ └── terragrunt.hcl
├── lambda_at_edge
│ └── env-dev
│ ├── 404_redirect
│ │ └── terragrunt.hcl
│ ├── cognito_auth
│ │ └── terragrunt.hcl
│ └── version
│ └── terragrunt.hcl
├── log_buckets
│ ├── commons
│ │ └── ireland
│ │ └── terragrunt.hcl
│ └── env-dev
│ ├── ireland
│ │ └── terragrunt.hcl
│ └── virginia
│ └── terragrunt.hcl
├── misc-assets-transcend
│ └── terragrunt.hcl
├── package.json
├── privacy-center
│ └── env-dev
│ └── terragrunt.hcl
├── spa-static-server
│ └── terragrunt.hcl
├── terragrunt-config-atlantis.hcl
├── terragrunt-config-commons.hcl
├── terragrunt-config-dev.hcl
├── terragrunt-config-local.hcl
├── terragrunt-config-prod.hcl
├── terragrunt-config-staging.hcl
├── terragrunt-config-testing.hcl
└── vault
├── README.md
├── ami
│ ├── README.md
│ └── main.pkr.hcl
├── env-dev
│ ├── cluster
│ │ ├── secrets
│ │ │ └── terragrunt.hcl
│ │ └── terragrunt.hcl
│ └── settings
│ ├── audit
│ │ └── terragrunt.hcl
│ ├── auth_backends
│ │ └── aws
│ │ └── terragrunt.hcl
│ ├── mounts
│ │ └── kv
│ │ └── terragrunt.hcl
│ └── roles
│ ├── atlantis_role
│ │ └── terragrunt.hcl
│ └── developer_role
│ └── terragrunt.hcl
├── provider.block
├── signRequest.js
├── vault-config-dev.block
├── vault-config-prod.block
└── vault-config-staging.blockDavidalmost 6 years ago
Those are just directories with terragrunt files, so it doesn't include any of our terraform (though we mostly use open source modules).
I also removed all the directories for staging/prod, as they are almost always the exact same as our env-dev directories. I'm not sure this is the best possible directory setup, but we haven't had any troubles with it really.
At the very top level of this structure, we have files named "terragrunt-config-dev", "terragrunt-config-staging", etc. that set up remote state, common inputs, tags, AWS infro, etc.
We use the
*.block files as common code (like providers) to generate and insert into our other terragrunt modulesDavidalmost 6 years ago
We don't use as many regions as it looks like you do yet, but we often have duplication across accounts/envs, and for those we do essentially duplicate the terragrunt config and let Atlantis take care of it
joshmyersalmost 6 years ago
e.g. to keep all the services using the same source remote release in lockstep across regions (so you only have to bump versions in one place) in the env.yaml for a given environment there is a place holder for each service version, but then bumping anything in there triggers all Atlantis projects to plan
joshmyersalmost 6 years ago
Not sure if that makes sense
joshmyersalmost 6 years ago
OK, so you have a shit ton of dirs and individual files to toggle too
joshmyersalmost 6 years ago
(not just me then)
joshmyersalmost 6 years ago
So you have thing>environment>region, interesting
Davidalmost 6 years ago
Yep, I love my small files. All the modules have really small blast radius in case anything goes wrong, or if I ever need to refactor/migrate resources to different terraform state
joshmyersalmost 6 years ago
Aye, nice
Davidalmost 6 years ago(edited)
For that particular project, here is the
cloc --vcs git .
So while we have tons of HCL, the files on average are <30 lines of actual code
cloc results:cloc --vcs git .
cloc --vcs git .
533 text files.
510 unique files.
Complex regular subexpression recursion limit (32766) exceeded at /usr/local/Cellar/cloc/1.84/libexec/bin/cloc line 9879.
Complex regular subexpression recursion limit (32766) exceeded at /usr/local/Cellar/cloc/1.84/libexec/bin/cloc line 9879.
38 files ignored.
<http://github.com/AlDanial/cloc|github.com/AlDanial/cloc> v 1.84 T=0.44 s (1133.1 files/s, 48260.4 lines/s)
--------------------------------------------------------------------------------
Language files blank comment code
--------------------------------------------------------------------------------
HCL 451 3267 2393 13403
JavaScript 18 130 365 627
Markdown 9 134 0 222
JSON 7 0 0 191
Dockerfile 5 33 36 128
Bourne Again Shell 2 28 16 90
Bourne Shell 3 5 6 8
--------------------------------------------------------------------------------
SUM: 495 3597 2816 14669
--------------------------------------------------------------------------------So while we have tons of HCL, the files on average are <30 lines of actual code
joshmyersalmost 6 years ago
I'm waiting for some PRs to drop but I think about a DRY refactor
joshmyersalmost 6 years ago
Yeah same, but still a few :p
joshmyersalmost 6 years ago
I want something like Hiera for Terraform
joshmyersalmost 6 years ago
Terragrunt 2 layer approach isn’t ideal
Davidalmost 6 years ago
Have you played around with pulumi at all? You could probably reduce a lot of boilerplate with the higher level language constructs
joshmyersalmost 6 years ago
Yeah, not keen. I want a DSL, not a full fledged language and it still uses the TF providers under the covers
joshmyersalmost 6 years ago
read_terragrunt_config doesn’t let you share locals between files, you can do stuff with inputs….but not locals…joshmyersalmost 6 years ago
You can use locals in inputs, but they aren’t quite the same
Tim Birkettalmost 6 years ago(edited)
Hey 👋 - Terragrunt v0.23.18 brought a nice new function:
sops_decrypt_file it allows you to decrypt either a JSON or YAML file that has been created with Mozilla's sops and use it as inputs to Terraform. Looks like a reasonable solution for those initial an innoying static keys and passwords that you'd otherwise have to manually create somewhere. https://terragrunt.gruntwork.io/docs/reference/built-in-functions/#sops_decrypt_fileaaratnover 5 years ago
Checkout terraform version manager written by me, supports pip, docker and homebrew !!
Its already becoming popular with 40 ⭐️ .
https://github.com/aaratn/terraenv
Its already becoming popular with 40 ⭐️ .
https://github.com/aaratn/terraenv
joeyover 5 years ago(edited)
related, i had been using tfenv, tgenv, helmenv, pyenv, and rvm until i recently learned of https://github.com/asdf-vm/asdf which also has support for many more things. 🤷♂️
joshmyersover 5 years ago
lol
Brij Sover 5 years ago
Hello! Does anyone here have any clever ways of actually managing the remote state infra thats created by terragrunt? (s3/dynamo). How does one remove/delete it in a sane manner 🤔
muhahaover 5 years ago
Is possible to define "projects" in terragrunt.hcl ? Like project: foo with path: a/b/c and then if is possible to run terragrunt apply --project foo
Brij Sover 5 years ago
Hey all, I’m using the
any way I can pass the tags?
generate block to create a backend for me, however I notice the tags dont get passed to it.remote_state {
backend = "s3"
generate = {
path = "backend.tf"
if_exists = "overwrite"
}
config = {
bucket = format("%s-state-%s", local.role_name, local.aws_region)
key = "terraform.tfstate"
region = local.aws_region
encrypt = true
dynamodb_table = format("%s-locks", local.role_name)
s3_bucket_tags = local.tags
dynamodb_table_tags = local.tags
skip_bucket_accesslogging = true
}
}any way I can pass the tags?