Below is my code to create the virtual servers and snats for F5 using terraform. I am unable to figure out how i can loop thru the map of snats that inside the for_each when creating the virtual server resources…
terraform.tfvars
snats = {
“GCPTEST.abc.COM” = “10.12.14.133”
“GCPTEST-2.abc.COM” = “10.12.14.134”
}
vs-names = {
“GCPTEST.abc.COM” = “10.12.13.221”
“GCPTEST-1.abc.COM” = “10.12.13.222”
}
main.tf
creation of SNAT - using for_each
resource “bigip_ltm_snatpool” “snatpool_gcptest” {
for_each = var.snats
name = “/{var.partition}/SNAT-{each.key}_{each.value}"
members = ["{each.value}”]
}
resource “bigip_ltm_virtual_server” “https” {
for_each = var.vs-names
name = “/{var.partition}/vs-{each.key}-443”
description = “Virtual server via Terraform”
source = var.internet-ip
destination = each.value
port = 443
source_address_translation = "snat"
snatpool = ????? how to loop thru the snats map ???
}