Given this resource:
resource "google_compute_instance" "instance" {
...
network_interface {
...
access_config {
...
}
}
}
I'd like to conditionally define the access_config property based on a condition.
resource "google_compute_instance" "instance" {
...
network_interface {
...
dynamic "access_config" {
for_each = var.condition ? [1] : []
content {
...
}
}
}
}
Similar to what Josep Nadal mentioned, but change count to for_each like
dynamic "access_config" {
for_each = var.conditional_on ? ["1"] : []
content {
nat_ip = null
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With