Solution to 'This value does not have any attributes.` with kubelet_identity.object_id

Got this today when trying to assign access_policy to kubelet_identity

Error: Unsupported attribute

  on line 59, in resource "azurerm_key_vault" "key_vault":
  59:     object_id = azurerm_kubernetes_cluster.aks.kubelet_identity.object_id

This value does not have any attributes.

This fixed it:

access_policy {
    tenant_id = data.azurerm_client_config.current.tenant_id
    object_id = azurerm_kubernetes_cluster.aks.kubelet_identity.0.object_id

    secret_permissions = [
      "get", "set", "list", "delete"

Looks like kubelet_identity is a list, so you need an index 0 before object_id