#terragrunt (2019-07)

terragrunt

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

2019-07-31

2019-07-30

me1249 avatar
me1249

Hey all - has anyone figured out a way to use a before_hook to set environment variables that terragrunt can use?

me1249 avatar
me1249

I’m using direnv for directory based variables which works fantastic for single plan/applies, but it won’t work with an apply-all

Erik Osterman (Cloud Posse) avatar
Erik Osterman (Cloud Posse)

It’s possible if you call direnv exec on the command in each directory

Erik Osterman (Cloud Posse) avatar
Erik Osterman (Cloud Posse)

But as @joshmyers hinted, it’s a bit dangerous

me1249 avatar
me1249

That doesn’t seem to work with a before hook

me1249 avatar
me1249

I have .envrc files in the child directories with overrides and region/module specific config

Erik Osterman (Cloud Posse) avatar
Erik Osterman (Cloud Posse)

can you share what you tried doing?

me1249 avatar
me1249

So I have a directory structure like so

account-id – nonprod\ —- test\ —— ap-southeast-2\ ——– app_name\ ———- .envrc ———- terragrunt.hcl ——– .envrc —- .envrc —- terragrunt.hcl

Each child directory can have an .envrc file that loads environment variables specific to it or it’s child directories (eg. region specific variables for a region folder and it’s children)

me1249 avatar
me1249

I tried using a before_hook to run a direnv reload - but that won’t work as it spawns a new child process

me1249 avatar
me1249

I can’t think of any way to get it to set environment variables before a terragrunt execution - so I thought about writing variables to a tfars. But this is going to block that idea: https://github.com/hashicorp/terraform/issues/19424

Terraform 0.12.0-alpha no longer allows assignments in terraform.tfvars without a corresponding variable declaration · Issue #19424 · hashicorp/terraform

Terraform Version Terraform v0.12.0-alpha2 + provider.google v1.19.1-4-gf3de5334 + provider.null v1.0.0-5-gf54ff98 Expected Behavior Terraform v0.11.10 and earlier allowed assignments to occur in t…

Erik Osterman (Cloud Posse) avatar
Erik Osterman (Cloud Posse)

are you using make too?

me1249 avatar
me1249

Not for any heavy lifting - just to run some basic scripts (eg. make new account creates a new terragrunt folder structure based on a template)

joshmyers avatar
joshmyers

Isn’t apply all a bit YOLO, considering you can’t plan-all and have it correctly reflect dependency changes as the apply on the former hasn’t run yet…?

:100:1
me1249 avatar
me1249

Only looking to do it for an initial spin up

davidvasandani avatar
davidvasandani

@me1249 if you figure this out, I’m interested in how you do it.

me1249 avatar
me1249

Unfortunately not

me1249 avatar
me1249

So create new aws account, run apply-all

1

2019-07-29

Sharanya avatar
Sharanya

Hey Folks, Trying to find some Terraform Modules related to AWS - app stream service ( for creating fleets and stacks) any help appreciated

2019-07-09

aaratn avatar
aaratn

Is anyone having issue with terraform 0.12 and terragrunt 0.19.8 not picking up credentials parameter when using gcs as backend ?

aaratn avatar
aaratn
terragrunt] [/Users/aarat/git/terraform/variables/staging] 2019/07/09 21:36:04 Initializing remote state for the gcs backend
[terragrunt] 2019/07/09 21:36:04 dialing: google: could not find default credentials. See <https://developers.google.com/accounts/docs/application-default-credentials> for more information.
aaratn avatar
aaratn

I am seeing this and unable to initialize

loren avatar
loren

there have been a handful of changes to GCS backend in recent versions, maybe try 0.19.5? if that works, open an issue describing your config and use case

loren avatar
loren
Terragrunt 0.19.6 breaks existing GCP config · Issue #767 · gruntwork-io/terragrunt

A working config on 0.19.5 now fails on 0.19.6 (likely due to GCP changes) I have this as a parent remote_state { backend = &quot;gcs&quot; config = { bucket = &quot;project-factory-592341-tfstate&…

    keyboard_arrow_up