Can't access attributes on a list of objects. Did you mean to access an attribute for a specific element of the list, or across all elements of the list? #3
│ Error: Unsupported attribute
│
│ on ..\_modules\environment_v1\_modules\container-apps\main.tf line 121, in resource "azurerm_container_app" "container_app":
│ 121: name = volume.value[each.value.template.volume.key].name
│ ├────────────────
│ │ each.value.template.volume is list of object with 1 element
│
│ Can't access attributes on a list of objects. Did you mean to access an attribute for a specific element of the list, or across all elements of the list?
╵
╷
│ Error: Unsupported attribute
│
│ on ..\_modules\environment_v1\_modules\container-apps\main.tf line 122, in resource "azurerm_container_app" "container_app":
│ 122: storage_name = volume.value[each.value.template.volume.key].storage_name
│ ├────────────────
│ │ each.value.template.volume is list of object with 1 element
│
│ Can't access attributes on a list of objects. Did you mean to access an attribute for a specific element of the list, or across all elements of the list?
╵
╷
│ Error: Unsupported attribute
│
│ on ..\_modules\environment_v1\_modules\container-apps\main.tf line 123, in resource "azurerm_container_app" "container_app":
│ 123: storage_type = volume.value[each.value.template.volume.key].storage_type
│ ├────────────────
│ │ each.value.template.volume is list of object with 1 element
│
│ Can't access attributes on a list of objects. Did you mean to access an attribute for a specific element of the list, or across all elements of the list?
Expected Behaviour
add volume to container
Actual Behaviour
error
Steps to Reproduce
terraform apply
Important Factoids
No response
References
Solution to the Problem for me:
dynamic "volume" {
for_each = each.value.template.volume == null ? [] : [each.value.template.volume]
Is there an existing issue for this?
Greenfield/Brownfield provisioning
greenfield
Terraform Version
3.51.0
Module Version
newest
AzureRM Provider Version
newest
Affected Resource(s)/Data Source(s)
azurerm_container_app
Terraform Configuration Files
tfvars variables values
Debug Output/Panic Output
Expected Behaviour
add volume to container
Actual Behaviour
error
Steps to Reproduce
terraform apply
Important Factoids
No response
References
Solution to the Problem for me: dynamic "volume" { for_each = each.value.template.volume == null ? [] : [each.value.template.volume]
(Added volume.key)