Hi, I’m trying to create a dynamic labels block inside google_compute_instance, but got the following error. The static
Error: Unsupported block type
on …/modules/gcp-single-instance/main.tf line 35, in resource “google_compute_instance” “default”:
35: dynamic “labels” {
Blocks of type “labels” are not expected here.
The commented static labels block works fine. I’m not sure why I can’t create a dynamic one.
locals {
labels = {
environment = var.env
application = var.app
}
}
resource “google_compute_instance” “default” {
name = “{local.instance_name}"
machine_type = "{var.machine_type}”
zone = “${var.zone}”
# labels = {
# foo = “bar”
# }
dynamic “labels” {
for_each = local.labels
content {
key = labels.key
value = labels.value
}
}
…
}
terraform --version
Terraform v0.12.20
- provider.dns v2.2.0
- provider.google v2.18.1
- provider.google-beta v2.18.1
- provider.random v2.2.1
- provider.template v2.1.2
- provider.vault v2.6.0