#terragrunt - January 2020

terragruntArchived
34 messages

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

January 2020
Milos Backonja
Milos Backonjaalmost 7 years ago
guys how to safely migrate state from one s3 bucket to another with terragrunt ?
Brij S
Brij Salmost 7 years ago
Ive got a terraform module that creates resources in two different aws accounts. I handle this by doing the following:
provider "aws" {
  region  = "us-west-2"
  profile = "profile1"
}

provider "aws" {
  region              = "us-west-2"
  profile             = "profile2"
  alias               = "digi"
}

And in the module itself, the different provider is picked up like this:
resource "aws_route53_record" "dig_ns" {
  provider = aws.digi

I'm trying to utilize terragrunt to deploy many modules. This becomes difficult since the above method no longer works, has anyone encountered this? If so, how have you got around this. I dont think Terragrunt supports multiple providers like this
Brij S
Brij Salmost 7 years ago
I dont quite understand how tg can use different providers/regions(if at all ) 🤔
slaughtr
slaughtralmost 7 years ago
I don't see why that wouldn't work, unless maybe you're on an older version?
Brij S
Brij Salmost 7 years ago
well, in the .hcl file you dont specify providers of any sort?
Brij S
Brij Salmost 7 years ago
or any profiles
slaughtr
slaughtralmost 7 years ago
True, but terragrunt is just applying terraform. So you should be able to leave your tf files more or less the same
Brij S
Brij Salmost 7 years ago
hmm, im confused
Brij S
Brij Salmost 7 years ago
the terragrunt docs mention only leaving .hcl files in the 'live' repo
slaughtr
slaughtralmost 7 years ago
I have only done some light testing around multiple providers in my TF but TG didn't seem to mind
Brij S
Brij Salmost 7 years ago
so if my tg file looked like this
include {
  path = find_in_parent_folders()
}

terraform {
  source = "git::git@github.com:foo/modules.git//app"
}

inputs = {
  zone_name       = "<http://domain.com|domain.com>"
  comment         = "Managed by Terraform"
Brij S
Brij Salmost 7 years ago
where do you plugin multiple providers
slaughtr
slaughtralmost 7 years ago
You put the multiple providers in your .tf files like you would normally
slaughtr
slaughtralmost 7 years ago
Terragrunt is just a wrapper for terraform, it doesn't need all that info
slaughtr
slaughtralmost 7 years ago
So if you had module.tf with multiple providers before, just point TG at it and it should (probably) just work
getSurreal
getSurrealalmost 7 years ago
replying in threads would be appreciated 😀
Brij S
Brij Salmost 7 years ago
sorry about that 🙂
Milos Backonja
Milos Backonjaalmost 7 years ago
Hi Guys, do you know if I can use terragrunt command in before hooks?
    before_hook "test" {
    commands     = ["init"]
    execute      = ["terragrunt", "apply", "-target=null_resource.rule", "-auto-approve"]
  }
joshmyers
joshmyersalmost 7 years ago
Isn’t that going to cause recursion issues?
loren
lorenalmost 7 years ago
depends on when the state is locked... i think it would work. does seem fragile though. but could be an interesting approach to dealing with the "count" cannot be computed style of error
loren
lorenalmost 7 years ago(edited)
would at least need to disable autoinit in the hook to avoid recursion, --terragrunt-no-auto-init
Milos Backonja
Milos Backonjaalmost 7 years ago
Thanks guys, eventually I dropped approach with null resource and use External Data Source
Chase Ward
Chase Wardalmost 7 years ago
@Chase Ward has joined the channel
Brij S
Brij Salmost 7 years ago
I'm having an issue where terragrunt ignores a providers assume role/iam role block when assuming a role and using the creds from that as env vars - has anyone dealt with this?
joshmyers
joshmyersalmost 7 years ago
@Brij S post what you have/what you problem is
joshmyers
joshmyersalmost 7 years ago
Have had similar but need exact info.
Adrian
Adrianalmost 7 years ago
I have some extra var files defined and want to use some variables from this files in input for example region in container task definition, is this possible?
David
Davidalmost 7 years ago
It is! What have you tried so far?
Adrian
Adrianalmost 7 years ago
Adrian
Adrianalmost 7 years ago
this is what i need
# stage/frontend-app/terragrunt.hcl
terraform {
  source = "..."
}

# Include all settings from the root terragrunt.hcl file
include {
  path = "${find_in_parent_folders()}"
}

inputs = {
  aws_region = get_input("aws_region")
  remote_state_bucket = get_input("remote_state_bucket")

  instance_type = "t2.micro"
  instance_count = 10
}
Adrian
Adrianalmost 7 years ago
aws_region is defined in tfvars which is included in optional_var_files
Adrian
Adrianalmost 7 years ago
how can I achieve this?
Adrian
Adrianalmost 7 years ago
  aws_region = get_input("aws_region")

joshmyers
joshmyersalmost 7 years ago
get_input isn’t a valid function.