Have a such configuration with for_each loop
I would like to pass availability_zone variables accordingly to provisioned shell script
got an err
Error: Cycle: module.proxyserver-instance.aws_instance.sa_proxy_server[“af-south-1c”], module.proxyserver-instance.aws_instance.sa_proxy_server[“af-south-1a”], module.proxyserver-instance.aws_instance.sa_proxy_server[“af-south-1b”]
variable "region" { default = "af-south-1" }
variable "sa_zones" {
type = map(any)
default = {
"af-south-1a" = "subnet-a36e81337"
"af-south-1b" = "subnet-9b2821337"
"af-south-1c" = "subnet-4b6a41337"
}
}
resource "aws_instance" "sa_proxy_server" {
for_each = var.region == "af-south-1" ? var.sa_zones : {}
availability_zone = each.key
ami = "ami-075ce95d3f9ecc1337"
instance_type = var.instance_type
subnet_id = each.value
security_groups = ["sg-01c0e662075c1337"]
tags = {
Name = "${var.hostname}-${each.key}"
}
provisioner "local-exec" {
# Add proxy hostname to required locations
command = "./bootstrap-proxy.sh ${aws_instance.sa_proxy_server.*.availability_zone}"
}
}
Is there any possibility to pass separate each key for shell script ?