我正在管理Terraform中的CosmosDB帐户,但每次计划时,它都希望设置default_identity_type。当我应用此方法时,状态文件并不反映更改-因此,在随后的计划中,它尝试再次应用相同的更改。
Azure中的实际资源已经存在了一段时间,我使用terraform import ...导入了状态。状态如下(删除敏感值):
{
"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是非常基本的,因为我只是对大多数属性使用默认值:
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版)出现了一些问题,但我仍然在经历这个问题。
有人有办法解决这个问题吗?
发布于 2022-01-10 07:14:48
我的声誉不允许我发表评论,但通常情况下,当Terraform坚持要更改资源时,它会告诉您该属性的当前值是什么,以及它希望将其更改为什么。(通常为null)
作为一种解决方法,尝试添加属性default_identity_type并将其设置为Terraform声明的任何值,然后再次运行一个计划,以查看它是否更改了行为。
编辑:我刚看了一下截图。因此,您应该设置为解决方案的值是"FirstPartyIdentity"。
看一下文档,它应该是可选的,但显然不是。也许这是文档中的一个错误。账号
https://stackoverflow.com/questions/70620034
复制相似问题