I had a main.tf custom TF module, the module will deploy a lists of another custom modules. I can deploy single region by passing single value into main.tf, but when I tried multi-region which passing an array of regions and loop in main.tf's custom module. It doesn't work.
main.tf
locals {
regions = ["asia-east2", "asia-southeast1"]
}
module "main" {
source = "./modules/main"
for_each = local.regions
region = each.value
}
Error:
The name "for_each" is reserved for use in a future version of Terraform.`
Notes
I know Terraform 0.12 doesn't support this feature. Is there a way to loop through multi-region without passing down into child module's resource level ?
for_eachattribute for Modules. So what you are asking to do is not possible at the moment. - GreenyMcDuff