#terragrunt (2020-04)

terragrunt

Terragrunt discussions

Archive: https://archive.sweetops.com/terragrunt/

2020-04-04

2020-04-14

David avatar

Just a heads up for anyone else making use or considering usage of read_terragrunt_config, the function is unfortunately in a bad state.

Issue originally pointing out a concern with the function: https://github.com/gruntwork-io/terragrunt/issues/1107 Follow up issue from a maintainer pointing out that the issue is very complicated to fix: https://github.com/gruntwork-io/terragrunt/issues/1128 Issue where a maintainer recommends against using the function at the moment: https://github.com/gruntwork-io/terragrunt/issues/303

I’ve hit some nastly bugs with it that are particularly hard to debug, so this is just a friendly suggestion that you all consider those issues before deciding to make use of it

Expose Dependencies from read_terragrunt_config calls in `PartialDecodeSectionType` · Issue #1107 · gruntwork-io/terragrunt

Hello! I am working on a go binary that generates atlantis config from terragrunt files. My repo is here: https://github.com/transcend-io/terragrunt-atlantis-config, and the part of my code that tr…

read_terragrunt_config with dependency is broken · Issue #1128 · gruntwork-io/terragrunt

Description read_terragrunt_config throws a wrench into the configuration parsing order due to the fact that the function can be called in locals blocks. This means that the loaded config has to be…

Only one level of includes is allowed · Issue #303 · gruntwork-io/terragrunt

I'm trying to enable a multi-include scenario where I can cascade includes at different points in my configurations. Given the below layout: └── root ├── regions │ ├── us-east-1 │ │ ├── regiona…

2020-04-28

joshmyers avatar
joshmyers

How many levels of dirs are folks ending up with given example Terragrunt repo? Does this put people off?

joshmyers avatar
joshmyers

my dev environment alone has 32 dirs….not sure how I feel about it….

joshmyers avatar
joshmyers
test/dev
├── env.hcl
├── eu-central-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
├── 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
    ├── 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

32 directories, 33 files
joshmyers avatar
joshmyers

Maybe @antonbabenko or others have thoughts as heavy Terragrunt users?

David avatar

At my company we have hundreds of modules per env :man-shrugging:

It became 1000% more manageable for us once we got into a good CI/CD flow with atlantis. So now the flow is:

• Make changes to the underlying modules • Run terragrunt-atlantis-config to generate atlantis config for our dependency graph • Open a PR • Atlantis plans everything that needs to be changed • Approve PR, apply all the plans with one command Sometimes those PRs can affect dozens of modules (especially because we do releases with staging and prod branches), but that’s no problem because it’s so easy to apply everything

Adrian avatar

What is your plan and apply run command?

    workflows = {
      stage = {
        plan = {
          steps = [
            {
              run = "terragrunt plan -no-color -out $PLANFILE"
            }
          ]
        },
        apply = {
          steps = [
            {
              run = "terragrunt apply -no-color $PLANFILE"
            }
          ]
        }
      }
    }

Did you try to hide all downloading message etc.?

David avatar

Ours is:

    workflows = {
        default = {
          plan = {
            steps = [
              # Verify that the user that commented "atlantis plan ..." is an admin
              { env = { name = "ADMINS", value = join(",", var.apply_admins) } },
              { run = "node ~/user_whitelist.js" },

              # Create the plan
              { run = "node ~/terragroan.js" },
            ]
          }
          apply = {
            steps = [
              # Verify that the user that commented "atlantis apply ..." is an admin
              { env = { name = "ADMINS", value = join(",", var.apply_admins) } },
              { run = "node ~/user_whitelist.js" },

              # Actually apply the plan
              { run = "terragrunt apply -no-color plan.out" },
            ]
          }
        }

The terragroan.js thing is the code in the gist here: https://gist.github.com/dmattia/0d17696bad1dffd90ec7c899e0343955

Adrian avatar

nice thanks

Adrian avatar

I changed it to

run = "terragrunt plan -no-color -out $PLANFILE 2> $PLANFILE.stderr || cat $PLANFILE.stderr"

maybe it will be enough

Adrian avatar

it show only stdout and stderr on exit code diff than 0

joshmyers avatar
joshmyers

@David Thanks for the reply. Yes we do the same but the Atlantis workflow isn’t perfect (mainly saying that based off Atlantis triggers but totally depends how you have laid out the repo) - but still not sure how I feel about all these dirs…

loren avatar

the gruntwork folks seem open to an alternative that maps it out in a single file, if you’d prefer a flatter approach. i think they were looking for help with that pr

loren avatar
RFC: single terragrunt.hcl per environment? · Issue #759 · gruntwork-io/terragrunt

Current state The current practice for using Terragrunt is to create one folder for each module and put a terragrunt.hcl file in it. You also have one terragrunt.hcl at the root of each environment…

joshmyers avatar
joshmyers

Hmm, maybe, not sure if that approach will play nicely with something like Atlantis though…

joshmyers avatar
joshmyers
staging
└── terragrunt.hcl
production
└── terragrunt.hcl
joshmyers avatar
joshmyers

Won’t work very well, a change to staging/terragrunt.hcl and Atlantis builds every staging project?

joshmyers avatar
joshmyers
staging
├── production
│   ├── apps.hcl
│   ├── data-stores.hcl
│   └── networking.hcl
└── staging
    ├── apps.hcl
    ├── data-stores.hcl
    └── networking.hcl
joshmyers avatar
joshmyers

could work…

loren avatar

Comment on the issue! I don’t think they’re looking at custom hcl filenames…

loren avatar

apps/terragrunt.hcl, etc, might work…

joshmyers avatar
joshmyers

The whole thing sounds very up in the air…

joshmyers avatar
joshmyers

Argh.

joshmyers avatar
joshmyers

Why is software so hard?

loren avatar

Lololol, anything software that is or looks easy has had some absolutely masterful designers and developers

1
    keyboard_arrow_up