Issues with dynamic blocks

Hi everyone,

Yesteraday, I encountered an issue with the last Terraform version (0.14.5) and the dynamic blocks : the iteration on locals or variables inside dynamic blocks.
Let me explain…

here the variable :

locals {
compute_firewall = [
{
id = “0”
name = join("-", [google_compute_network.compute_network.name, “allow-ssh-from-specific-vpc”])
allow = [
{
protocol = “tcp”
ports = [“22”]
}
]
},
{
id = “1”
name = join("-", [google_compute_network.compute_network.name, “allow-icmp-from-specific-vpc”])
allow = [
{
protocol = “icmp”
}
]
}
]
}

and the resource that need to be created :

resource “google_compute_firewall” “compute_firewall” {
count = length(local.compute_firewall)
name = lookup(local.compute_firewall[count.index], “name”)
network = google_compute_network.compute_network.self_link
project = local.project_id
direction = “INGRESS”
source_ranges = [var.vpc_cidr, var.host_project_vpc_cidr]

dynamic “allow” {
for_each = lookup(local.compute_firewall[count.index], “allow”) == null ? : lookup(local.compute_firewall[count.index], “allow”)
content {
protocol = lookup(allow.value, “protocol”)
ports = lookup(allow.value, “ports”, null)
}
}
}

Strangely, with the 0.12 versions, it worked perfectly…but each time I tried with the latest version (0.14.5, the 0.14.2 made terraform crashing), terraform seems to not like it.

Is there somebody here encountered the same issue ?
Thanks for any help :slight_smile:

Could you please share the error.