Dynamic block error Blocks of type "metadata" are not expected here

Hi, I am trying to create a dynamic block for a google_compute_instance nested block, but keep getting the error Blocks of type "metadata" are not expected here

The code for the blocks(without using dynamic) should look like

metadata = {
   ssh-keys = "user:rsakeyefwefewfwefefwetc"
 }
metadata = {
   ssh-keys = "user2:rsakey2efwefewfwefefwetc"
 }

and here is my try at using the dynamic feature of TF

  dynamic "metadata" {
    for_each = var.ssh_keys_map
    content {
      ssh-keys = "${metadata.value.user}:${metadata.value.key}"
    }
  }

Any idea what I am doing wrong?

Hi @kinwolfqc,
metadata here isn’t a block, so you can’t use the dynamic block construct to create additional values. You can use a for expression to assign the desired value to attribute.