Help accessing part of a data source

Hi there

Sorry to trouble you but I’ve ran out of things to try within the terraform console.

I’m trying to access the name field.
image

if I wild card the external_network (which is a little smelly :frowning: ), I end up with a list but not a string I can access.
data.vcd_edgegateway.vcloud_tenant_edge.external_network[*].name

I would apprecate your help

Best Regards

Gary

Hi @username-is-already,

If you know that there will always be only one external network associated with this gateway, you can use the one function to assert that and take just that one value from the set.

one(data.vcd_edgegateway.vcloud_tenant_edge.external_network[*].name)

The behavior of one means the following three possibilities:

  • If there’s exactly one element in this set then it’ll return the name of that one element. (This is the situation in the screenshot you shared.)
  • If there are no elements in this set then it’ll return null, which represents the absense of a value.
  • Otherwise it’ll return an error, indicating that you need to do something more involved in order to explain to Terraform how to select the one element you want to access.

Thank you @apparentlymart for your help, I really appreciate it.