Last active
September 12, 2022 15:30
-
-
Save hoo29/107d3612166458afc0616169f4c1e55a to your computer and use it in GitHub Desktop.
Terraform
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# These variables are declared as locals here for brevity but could equally be terraform variables, a terraform http data source, output from another module etc. | |
locals { | |
deployment_targets = { | |
# region = aws account id | |
"eu-west-1" = "00000000000" | |
"eu-west-2" = "11111111111" | |
} | |
module_version = "1.2.3" | |
} | |
provider "aws" { | |
for_each = local.deployment_targets # <- not allowed | |
alias = "${each.value}${each.value}" | |
region = each.key | |
assume_role { | |
role_arn = "arn:aws:iam::${each.value}:role/Iac" | |
} | |
} | |
module "cool_module" { | |
for_each = local.deployment_targets | |
source = "./modules/super_secure_module" | |
providers = { | |
aws = "aws.${each.value}${each.value}" # <- not allowed | |
} | |
} | |
module "super_cool_module" { | |
source = "terraform_registry" | |
version = local.module_version # <- not allowed | |
} | |
module "ultra_cool_module" { | |
source = "github.com/repo/my_module?ref=${local.module_version}" # <- not allowed | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment