-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Closed
Labels
Description
I have a test which grabs a Terraform output which is a list of objects (Azure public IP addresses).
output "public_ip_addresses" {
value = azurerm_public_ip.all
}
The referenced resource azurerm_public_ip.all
contains the for_each
argument, so the output is a list of objects. So terraform output -json public_ip_addresses
would give something like
{
"pip1": {
"allocation_method": "Static",
"availability_zone": "2",
"domain_name_label": null,
"fqdn": null,
"id": "/subscriptions/someguid/resourceGroups/example/providers/Microsoft.Network/publicIPAddresses/pip-example-1",
"idle_timeout_in_minutes": 15,
"ip_address": "1.2.3.4",
"ip_tags": null,
"ip_version": "IPv4",
"location": "westeurope",
"name": "pip-example-1",
"public_ip_prefix_id": null,
"resource_group_name": "example",
"reverse_fqdn": null,
"sku": "Standard",
"sku_tier": "Regional",
"tags": {
"foo": "bar"
},
"timeouts": null,
"zones": [
"2"
]
},
"pip2": {
"allocation_method": "Static",
...etc...
}
}
I have a unit test that tries to retrieve this output in a useful form using
tfOutput := terraform.OutputMapOfObjects(t, terraformOptions, "public_ip_addresses")
But it throws an error "Type switching to map[string]interface{} failed."
This seems to happen at the point it tries to parse the zones
property of the first object in the map, as it is a list:
terratest/modules/terraform/output.go
Line 62 in cb603f1
err := errors.New("Type switching to map[string]interface{} failed.") |
asnowfix, idahobean, Pinaki-1, bernardhalas, bsch150 and 5 more