2

I have no idea if this would work, but I would like to use terragrunt to generate my providers blocks dynamically. Dynamic providers are currently not allowed (https://github.com/hashicorp/terraform/issues/19932).

I see this as a possible workaround.

Use a data "aws_organizations_organization" "all" {} to gather account info Then use a loop with that data to do something like this

generate "provider" {
  path = "provider.tf"
  if_exists = "overwrite_terragrunt"
  contents = <<EOF
provider "aws" {
  for_each = data.aws_organizations_organization.all
  assume_role {
    role_arn = each.role_arn //#built dynamically of couse
  }
alias = each.account.data.aws_organizations_organization.all.[k].account_name

}
EOF
}

I just can't find any info on looping in terragrunt.

Josh Beauregard
  • 2,498
  • 2
  • 20
  • 37

0 Answers0