Dynamic block for docker container. Blocks of type "env" are not expected here

Hello, whne I’m trying to use a dynamic block for my docker_container
m getting the issue below:

resource "docker_container" "myapp" {
  for_each = var.image_map
  name     = each.key
  image    = each.value.image

  dynamic "env" {
    for_each = var.vault_data_map
    content {
      VAULT_USERNAME = env.value.vault_user
      VAULT_PASSWORD = env.value.vault_password
    }
  }
...
}

│ Error: Unsupported block type

│ on …/main.tf line 17, in resource “docker_container” “myapp”:
│ 17: dynamic “env” {

│ Blocks of type “env” are not expected here.

What would be the right way to do it?
Thanks!

I’m assuming this is the kreuzwerker/docker provider. If you look at the resource documentation (Terraform Registry) there is no block “env”. Instead there is an attribute that accepts a set of string pf key=value pairs.

1 Like

Oh! Indeed!
I need to find another solution then.

Thanks for the clarification!
Cheers.