I'm trying to use terraform variable data (CSV file) to create a resource group and the name of the resource group is added into the CSV file. I'm currently experiencing the below error
│ Error: Unsupported attribute │ │ on testtf.tf line 11, in resource "azurerm_resource_group" "Main": │ 11: name = local.resource_groupname[count.index].groupname │ ├──────────────── │ │ count.index is a number, known only after apply │ │ local.resource_groupname is list of object with 3 elements │ │ This object does not have an attribute named "groupname".
Code
provider "azurerm" {
features{}
}
locals {
resource_groupname = csvdecode(file("./test.csv"))
}
resource "azurerm_resource_group" "Main" {
count = length(local.resource_groupname)
name = local.resource_groupname[count.index].groupname
location = "North europe"
}
./test.csv content
https://drive.google.com/file/d/1ituKDzaMVXnyynkjLBZRzMdWK9tnkL14/view?usp=sharing