The given key does not identify an element in this collection value/each.value is object with 5 attributes

Hello - I had 2 azure storage accounts. I need to add a 3rd with 2 additional attributes. So the plan is to add the configuration for those 2 attributes to the existing accounts configuration in order to keep things uniform.

After adding these, I’m getting a The given key does not identify an element in this collection value.

Although I have defined these attributes for the 3 accounts.

The below is an instance of the error, but I am seeing it 6 times - once for each new attribute for all three accounts.

│ Error: Invalid index
        │ 
        │   on storage.tf line 48, in resource "azurerm_storage_account" "storage-account":
        │   48:   is_hns_enabled           = each.value["is_hns_enabled"]
        │     ├────────────────
        │     │ each.value is object with 5 attributes
        │ 
        │ The given key does not identify an element in this collection value.

Terraform

"azurerm_storage_account" "storage-account" {
          for_each                 = var.storage_accounts
          name                     = substr(replace(lower(each.key), "/\\W|_|\\s/", ""), 0, 24)
          resource_group_name      = var.azure["resource_group_name"]
          location                 = var.azure["location"]
          account_tier             = each.value["account_tier"]

         # NEW ATTRIBUTE 
          account_kind             = each.value["account_kind"]

         # NEW ATTRIBUTE 
          is_hns_enabled           = each.value["is_hns_enabled"]

          account_replication_type = each.value["account_replication_type"]
        
          blob_properties {
            versioning_enabled = each.value["versioning_enabled"]
          }
        }

var.azure attributes are properly defined in another file, here are the storage_account vars

storage_accounts = {
      acct1 = {
        account_tier             = "Premium"

         # NEW ATTRIBUTE 
        account_kind             = "BlockBlobStorage"

        account_replication_type = "RAGRS"
        versioning_enabled       = false

         # NEW ATTRIBUTE 
        is_hns_enabled           = false

        roles                    = []
        containers = [
          {
            name        = "container1"
            access_type = "private"
          }
        ]
      }
    },
    ... other 2 accounts

I cannot find the issue in the code and I’m wondering if this is an order of operations issue that multiple steps to navigate the state change. Thank you for any tips.

There’s a variable spec file that defines the storage_accounts “type” explicitly. I didn’t know the file existed but I needed to conform to it.