Hello
I have created a data source based on a multi-instance resource.
sample code below.
data "vra_cloud_account_vsphere" "this" {
for_each = {
for account in local.fa : "${account.name}.${account.hostname}" => account
}
name = each.value.name
}
I am trying to get the id
of the data source using name
but couldn’t achieve to get it while there is a dot notation in the attribute. Is there a way to handle this while I want to keep the dot notation in the attribute.
here is the output when I try data.vra_cloud_account_vsphere.this
in terraform console. I did massage some data below.
{
"ac1.prod.domain.com.ac1.prod.domain.com" = {
"associated_cloud_account_ids" = tolist([])
"created_at" = "2021-10-05"
"custom_properties" = tomap({
"acceptSelfSignedCertificate" = "true"
"buildNumber" = "18485185"
})
"dcid" = ""
"description" = "ac1 Hosting Production vCenter"
"enabled_region_ids" = tolist([
"Datacenter:datacenter-26",
"Datacenter:datacenter-253",
"Datacenter:datacenter-21",
"Datacenter:datacenter-1014",
])
"hostname" = "ac1.prod.domain.com"
"id" = "37840775-7761-44b9-b4ca-cf68008e25ff"
"name" = "ac1.prod.domain.com"
"org_id" = "0d24d0a8-ef40-4e48-8fb1-bd737d423935"
"owner" = ""
"tags" = toset([])
"updated_at" = "2021-10-07"
"username" = tostring(null)
}
"ac2.prod.domain.com.ac2.prod.domain.com" = {
"associated_cloud_account_ids" = tolist([])
"created_at" = "2021-10-05"
"custom_properties" = tomap({
"acceptSelfSignedCertificate" = "true"
"buildNumber" = "18485185"
})
"dcid" = ""
"description" = "ac2 Hosting Production vCenter"
"enabled_region_ids" = tolist([
"Datacenter:datacenter-21",
"Datacenter:datacenter-26",
])
"hostname" = "ac2.prod.domain.com"
"id" = "a985552f-97c6-4d06-b4d8-b9f031b89caa"
"name" = "ac2.prod.domain.com"
"org_id" = "0d24d0a8-ef40-4e48-8fb1-bd737d423935"
"owner" = ""
"tags" = toset([])
"updated_at" = "2021-10-07"
"username" = tostring(null)
}
}
here is error I get when I run data.vra_cloud_account_vsphere.this["ac1.prod.domain.com.ac1.prod.domain.com"]
from tf console.
Error: Invalid index
on <console-input> line 1:
(source code not available)
|----------------
| data.vra_cloud_account_vsphere.name_map is object with 2 attributes
The given key does not identify an element in this collection value.