Getting error when try to retrieve the image for a azure container app with terraform

105 views Asked by At

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:

enter image description here

1

There are 1 answers

0
Lorenzo Felletti On BEST ANSWER

Form the error message I'm guessing template is a list itself, thus you should do something like:

output "return_value" {
    value = data.azurerm_container_app.aca.template[0].container[0].image
}