Unable to create azurerm_cosmosdb_sql_container with indexing_policy block

547 Views Asked by At

According to the documentation on Terraform.io for azurerm_cosmosdb_sql_container, it says I can include an indexing_policy block. However, when I run terraform plan I get errors:

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\"/?"
    }
  }
}

Here is my terraform version output:

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
1

There are 1 best solutions below

0
On BEST ANSWER

After searching GitHub, I finally found that support for the indexing_policy block was added in this commit 26 days ago. The documentation doesn't mention this, nor does the release notes for azurerm v2.31.1. After updating my main.tf file with the latest version for azurerm and running terraform init the terraform plan command worked without issue.

provider "azurerm" {
  version         = "~>2.31.1"
  features {}
}