I am writing a terraform code and getting "Can't access attributes on a list of objects." error when try to retrieve the image of container.
Below is the code
terraform {
required_providers {
azurerm = {
source = "hashicorp/azurerm"
version = "3.76.0"
}
}
}
provider "azurerm" {
features {
}
}
data "azurerm_container_app" "aca" {
name = "containername"
resource_group_name = "resourcegroupname"
}
output "return_value" {
value = data.azurerm_container_app.aca.template.container[0].image
}
Error:
Form the error message I'm guessing
template
is a list itself, thus you should do something like: