title: Managing Azure CosmosDB Account in terraform - state doesnt get updated properly after apply
body: <p>I am managing a CosmosDB account in Terraform, but every time I plan it wants to set the <code>default_identity_type</code>.  When I apply this, the state file doesn't reflect the change - therefore on subsequent plans it tries to apply the same change again.</p>
  <p>The actual resource in Azure has existed for some time, and I imported the state using <code>terraform import ...</code>.  The state looks like this (with sensitive values removed):</p>
  <pre><code>{
        &quot;module&quot;: &quot;module.main&quot;,
        &quot;mode&quot;: &quot;managed&quot;,
        &quot;type&quot;: &quot;azurerm_cosmosdb_account&quot;,
        &quot;name&quot;: &quot;root&quot;,
        &quot;provider&quot;: &quot;provider[\&quot;registry.terraform.io/hashicorp/azurerm\&quot;]&quot;,
        &quot;instances&quot;: [
          {
            &quot;schema_version&quot;: 0,
            &quot;attributes&quot;: {
              &quot;access_key_metadata_writes_enabled&quot;: true,
              &quot;analytical_storage&quot;: [
                {
                  &quot;schema_type&quot;: &quot;&quot;
                }
              ],
              &quot;analytical_storage_enabled&quot;: false,
              &quot;backup&quot;: [
                {
                  &quot;interval_in_minutes&quot;: 1440,
                  &quot;retention_in_hours&quot;: 48,
                  &quot;storage_redundancy&quot;: &quot;Geo&quot;,
                  &quot;type&quot;: &quot;Periodic&quot;
                }
              ],
              &quot;capabilities&quot;: [
                {
                  &quot;name&quot;: &quot;EnableServerless&quot;
                }
              ],
              &quot;capacity&quot;: [],
              &quot;consistency_policy&quot;: [
                {
                  &quot;consistency_level&quot;: &quot;Session&quot;,
                  &quot;max_interval_in_seconds&quot;: 5,
                  &quot;max_staleness_prefix&quot;: 100
                }
              ],
              &quot;cors_rule&quot;: [],
              &quot;create_mode&quot;: &quot;&quot;,
              &quot;default_identity_type&quot;: &quot;&quot;,
              &quot;enable_automatic_failover&quot;: false,
              &quot;enable_free_tier&quot;: false,
              &quot;enable_multiple_write_locations&quot;: false,
              &quot;geo_location&quot;: [
                {
                  &quot;failover_priority&quot;: 0,
                  &quot;location&quot;: &quot;northeurope&quot;,
                  &quot;prefix&quot;: &quot;&quot;,
                  &quot;zone_redundant&quot;: false
                }
              ],
              &quot;identity&quot;: [],
              &quot;ip_range_filter&quot;: &quot;&quot;,
              &quot;is_virtual_network_filter_enabled&quot;: false,
              &quot;key_vault_key_id&quot;: null,
              &quot;kind&quot;: &quot;GlobalDocumentDB&quot;,
              &quot;local_authentication_disabled&quot;: false,
              &quot;location&quot;: &quot;northeurope&quot;,
              &quot;mongo_server_version&quot;: null,
              &quot;network_acl_bypass_for_azure_services&quot;: false,
              &quot;network_acl_bypass_ids&quot;: [],
              &quot;offer_type&quot;: &quot;Standard&quot;,
              &quot;public_network_access_enabled&quot;: true,
              &quot;resource_group_name&quot;: &quot;dev&quot;,
              &quot;restore&quot;: [],
              &quot;timeouts&quot;: {
                &quot;create&quot;: null,
                &quot;delete&quot;: null,
                &quot;read&quot;: null,
                &quot;update&quot;: null
              },
              &quot;virtual_network_rule&quot;: []
            },
            &quot;sensitive_attributes&quot;: [],
            &quot;dependencies&quot;: [
              &quot;module.main.azurerm_resource_group.main&quot;,
              &quot;module.main.azurerm_resource_group.root&quot;
            ]
          }
        ]
      }
  </code></pre>
  <p>So when I <code>plan</code> I get:
  <a href="https://i.stack.imgur.com/Fveyv.png" rel="nofollow noreferrer">update in-place warning</a></p>
  <p>My terraform is very basic, as I'm just using the default values for most properties:</p>
  <pre><code>resource &quot;azurerm_cosmosdb_account&quot; &quot;root&quot; {
    name                  = &quot;some-name&quot;
    location              = azurerm_resource_group.root.location
    offer_type            = &quot;Standard&quot;
    resource_group_name   = azurerm_resource_group.root.name
    kind                  = &quot;GlobalDocumentDB&quot;
  
    geo_location {
      failover_priority   = 0
      location            = azurerm_resource_group.root.location
    }
  
    consistency_policy {
      consistency_level   = &quot;Session&quot;
    }
  
    tags                  = merge(var.tags, var.cosmosdb_account_tags)
  }
  </code></pre>
  <p>There have been issues raised surrounding the use of <code>default_identity_type</code> recently and updates to the AzureRM provider (up to version 2.90) but I'm still experiencing this issue.</p>
  <p>Does anyone have any workarounds for this?</p>