首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >管理terraform状态的Azure CosmosDB帐户申请后不会得到适当的更新。

管理terraform状态的Azure CosmosDB帐户申请后不会得到适当的更新。
EN

Stack Overflow用户
提问于 2022-01-07 10:45:20
回答 1查看 480关注 0票数 0

我正在管理Terraform中的CosmosDB帐户,但每次计划时,它都希望设置default_identity_type。当我应用此方法时,状态文件并不反映更改-因此,在随后的计划中,它尝试再次应用相同的更改。

Azure中的实际资源已经存在了一段时间,我使用terraform import ...导入了状态。状态如下(删除敏感值):

代码语言:javascript
运行
复制
{
      "module": "module.main",
      "mode": "managed",
      "type": "azurerm_cosmosdb_account",
      "name": "root",
      "provider": "provider[\"registry.terraform.io/hashicorp/azurerm\"]",
      "instances": [
        {
          "schema_version": 0,
          "attributes": {
            "access_key_metadata_writes_enabled": true,
            "analytical_storage": [
              {
                "schema_type": ""
              }
            ],
            "analytical_storage_enabled": false,
            "backup": [
              {
                "interval_in_minutes": 1440,
                "retention_in_hours": 48,
                "storage_redundancy": "Geo",
                "type": "Periodic"
              }
            ],
            "capabilities": [
              {
                "name": "EnableServerless"
              }
            ],
            "capacity": [],
            "consistency_policy": [
              {
                "consistency_level": "Session",
                "max_interval_in_seconds": 5,
                "max_staleness_prefix": 100
              }
            ],
            "cors_rule": [],
            "create_mode": "",
            "default_identity_type": "",
            "enable_automatic_failover": false,
            "enable_free_tier": false,
            "enable_multiple_write_locations": false,
            "geo_location": [
              {
                "failover_priority": 0,
                "location": "northeurope",
                "prefix": "",
                "zone_redundant": false
              }
            ],
            "identity": [],
            "ip_range_filter": "",
            "is_virtual_network_filter_enabled": false,
            "key_vault_key_id": null,
            "kind": "GlobalDocumentDB",
            "local_authentication_disabled": false,
            "location": "northeurope",
            "mongo_server_version": null,
            "network_acl_bypass_for_azure_services": false,
            "network_acl_bypass_ids": [],
            "offer_type": "Standard",
            "public_network_access_enabled": true,
            "resource_group_name": "dev",
            "restore": [],
            "timeouts": {
              "create": null,
              "delete": null,
              "read": null,
              "update": null
            },
            "virtual_network_rule": []
          },
          "sensitive_attributes": [],
          "dependencies": [
            "module.main.azurerm_resource_group.main",
            "module.main.azurerm_resource_group.root"
          ]
        }
      ]
    }

所以当我plan时,我得到:更新就地警告

我的terraform是非常基本的,因为我只是对大多数属性使用默认值:

代码语言:javascript
运行
复制
resource "azurerm_cosmosdb_account" "root" {
  name                  = "some-name"
  location              = azurerm_resource_group.root.location
  offer_type            = "Standard"
  resource_group_name   = azurerm_resource_group.root.name
  kind                  = "GlobalDocumentDB"

  geo_location {
    failover_priority   = 0
    location            = azurerm_resource_group.root.location
  }

  consistency_policy {
    consistency_level   = "Session"
  }

  tags                  = merge(var.tags, var.cosmosdb_account_tags)
}

最近围绕default_identity_type的使用和对AzureRM提供者的更新(直到2.90版)出现了一些问题,但我仍然在经历这个问题。

有人有办法解决这个问题吗?

EN

回答 1

Stack Overflow用户

发布于 2022-01-10 07:14:48

我的声誉不允许我发表评论,但通常情况下,当Terraform坚持要更改资源时,它会告诉您该属性的当前值是什么,以及它希望将其更改为什么。(通常为null)

作为一种解决方法,尝试添加属性default_identity_type并将其设置为Terraform声明的任何值,然后再次运行一个计划,以查看它是否更改了行为。

编辑:我刚看了一下截图。因此,您应该设置为解决方案的值是"FirstPartyIdentity"

看一下文档,它应该是可选的,但显然不是。也许这是文档中的一个错误。账号

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/70620034

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档