I am using version = “=2.30.0”
Applying following terraform configuration :
Terraform will perform the following actions:
# azurerm_cosmosdb_mongo_collection.content-service-publishedContent-chunks will be created
+ resource "azurerm_cosmosdb_mongo_collection" "content-service-publishedContent-chunks" {
+ account_name = "***"
+ database_name = "content-service"
+ default_ttl_seconds = 864000
+ id = (known after apply)
+ name = "publishedContent.chunks"
+ resource_group_name = "content-service"
+ shard_key = "files_id"
+ system_indexes = (known after apply)
+ throughput = 4000
+ index {
+ keys = [
+ "files_id",
+ "n",
]
+ unique = true
}
+ index {
+ keys = [
+ "n",
]
+ unique = false
}
}
Plan: 1 to add, 0 to change, 0 to destroy.
Do you want to perform these actions?
Terraform will perform the actions described above.
Only 'yes' will be accepted to approve.
Enter a value: yes
azurerm_cosmosdb_mongo_collection.content-service-publishedContent-chunks: Creating...
azurerm_cosmosdb_mongo_collection.content-service-publishedContent-chunks: Still creating... [10s elapsed]
azurerm_cosmosdb_mongo_collection.content-service-publishedContent-chunks: Still creating... [20s elapsed]
azurerm_cosmosdb_mongo_collection.content-service-publishedContent-chunks: Still creating... [30s elapsed]
azurerm_cosmosdb_mongo_collection.content-service-publishedContent-chunks: Still creating... [40s elapsed]
azurerm_cosmosdb_mongo_collection.content-service-publishedContent-chunks: Still creating... [50s elapsed]
azurerm_cosmosdb_mongo_collection.content-service-publishedContent-chunks: Still creating... [1m0s elapsed]
Error: Error waiting on create/update future for Cosmos Mongo Collection "publishedContent.chunks" (Account: "va7intcontentservicedbqr3jehdi", Database: "content-service"): Code="BadRequest" Message="Index definition does not contains '_id' index specification.
Now, if we also pass _id
in index, everytime we apply, shows following:
# azurerm_cosmosdb_mongo_collection.content-service-publishedContent-chunks will be updated in-place
~ resource "azurerm_cosmosdb_mongo_collection" "content-service-publishedContent-chunks" {
account_name = "****"
database_name = "content-service"
default_ttl_seconds = 864000
id = "****"
name = "publishedContent.chunks"
resource_group_name = "content-service"
shard_key = "files_id"
system_indexes = [
{
keys = [
"_id",
]
unique = true
},
]
throughput = 4000
+ index {
+ keys = [
+ "_id",
]
+ unique = false
}
index {
keys = [
"files_id",
"n",
]
unique = true
}
index {
keys = [
"n",
]
unique = false
}
}
If I explicitly specify unique index for _id
and set to true, then also it complains as follows:
+ index {
+ keys = [
+ "_id",
]
+ unique = true
}