How to declare name value kind of variables in terraform

Hello ,

I am trying to pass multiple name & value variables to rancher2_cluster_v2
on argument agent_env_vars .

I want to pass

name = a
value = b

name = c
value = d

name = e
value = f

rancher2_cluster_v2 | Resources | rancher/rancher2 | Terraform Registry

If I just pass all values it gives me below error

│   on main.tf line 62, in resource "rancher2_cluster_v2" "foo":
│   62:     name = "NO_PROXY"
│
│ The argument "name" was already set at main.tf:58,5-9. Each argument may be set only once.

Can anyone please help ? Highly appreciate .

The documentation describes agent_env_vars as a nested block.

That means (to people who know Terraform well already) that it wants:

resource "rancher2_cluster_v2" "cluster_name" {
  agent_env_vars {
    name  = "VARIABLE1"
    value = "VALUE1"
  }
  agent_env_vars {
    name  = "VARIABLE2"
    value = "VALUE2"
  }
  agent_env_vars {
    name  = "VARIABLE3"
    value = "VALUE3"
  }
}

It is misleading that you have to write agent_env_vars when actually each time you write that you are defining only 1 single env var.

Absolutely , thanks for pointing me in right direction. That suggestion has worked.