无法使用 indexing_policy 块创建 azurerm_cosmosdb_sql_container
Unable to create azurerm_cosmosdb_sql_container with indexing_policy block
根据 azurerm_cosmosdb_sql_container 的 documentation on Terraform.io,它说我可以包含一个 indexing_policy 块。但是,当我 运行 terraform plan
时出现错误:
Error: Unsupported block type
on main.tf line 912, in resource "azurerm_cosmosdb_sql_container"
"AccountActivity": 912: indexing_policy {
Blocks of type "indexing_policy" are not expected here.
main.tf
resource "azurerm_cosmosdb_sql_container" "AccountActivity" {
name = "AccountActivity"
resource_group_name = azurerm_resource_group.backendResourceGroup.name
account_name = azurerm_cosmosdb_account.AzureCosmosAccount.name
database_name = azurerm_cosmosdb_sql_database.AzureCosmosDbCache.name
default_ttl = 2592000
throughput = 2500
indexing_policy {
indexing_mode = "Consistent"
included_path {
path = "/*"
}
excluded_path {
path = "/\"_etag\"/?"
}
}
}
这是我的 terraform version
输出:
terraform version
Terraform v0.13.4
+ provider registry.terraform.io/-/azurerm v2.30.0
+ provider registry.terraform.io/hashicorp/azurerm v2.20.0
+ provider registry.terraform.io/hashicorp/random v2.3.0
搜索GitHub后,终于发现添加了对indexing_policy块的支持in this commit 26 days ago. The documentation doesn't mention this, nor does the release notes for azurerm v2.31.1。使用最新版本的 azurerm 和 运行 terraform init
更新我的 main.tf 文件后,terraform plan
命令正常工作。
provider "azurerm" {
version = "~>2.31.1"
features {}
}
根据 azurerm_cosmosdb_sql_container 的 documentation on Terraform.io,它说我可以包含一个 indexing_policy 块。但是,当我 运行 terraform plan
时出现错误:
Error: Unsupported block type
on main.tf line 912, in resource "azurerm_cosmosdb_sql_container" "AccountActivity": 912: indexing_policy {
Blocks of type "indexing_policy" are not expected here.
main.tf
resource "azurerm_cosmosdb_sql_container" "AccountActivity" {
name = "AccountActivity"
resource_group_name = azurerm_resource_group.backendResourceGroup.name
account_name = azurerm_cosmosdb_account.AzureCosmosAccount.name
database_name = azurerm_cosmosdb_sql_database.AzureCosmosDbCache.name
default_ttl = 2592000
throughput = 2500
indexing_policy {
indexing_mode = "Consistent"
included_path {
path = "/*"
}
excluded_path {
path = "/\"_etag\"/?"
}
}
}
这是我的 terraform version
输出:
terraform version
Terraform v0.13.4
+ provider registry.terraform.io/-/azurerm v2.30.0
+ provider registry.terraform.io/hashicorp/azurerm v2.20.0
+ provider registry.terraform.io/hashicorp/random v2.3.0
搜索GitHub后,终于发现添加了对indexing_policy块的支持in this commit 26 days ago. The documentation doesn't mention this, nor does the release notes for azurerm v2.31.1。使用最新版本的 azurerm 和 运行 terraform init
更新我的 main.tf 文件后,terraform plan
命令正常工作。
provider "azurerm" {
version = "~>2.31.1"
features {}
}