Open landintrees opened 6 months ago
Note that this only started failing sometime after 5th Feb 2024 as we have been running this same plan regularly before that date.
Our workaround is to remove unique = true from the _id index. This allows the terraform apply to complete successfully but future applies continuously nag with the following change:
- index {
- keys = [
- "_id",
] -> null
- unique = true -> null
}
+ index {
+ keys = [
+ "_id",
]
+ unique = false
}
However this does not actually change anything when applied.
According to the Microsoft docs uniqueness is enforced on _id anyway.
@landintrees Thanks for taking the time to open this issue. I believe this PR in addition to the service team's fix mentioned in the description will resolve this issue, #24817
Hi @landintrees, I am really grateful that you spotted it. How did you proceed with the workaround? Did you update the tfstate manually as well?
Hi @M3LiNdRu, we simple removed the "unique = true" from the _id index:
index {
keys = [
"_id"
]
unique = true <-- removed this line
}
As mentioned above terraform adds "unique = false" back on every apply but this makes no difference to the actual index in cosmos (we've confirmed this). It does make the plans a bit messy if you have a lot of collections but we can put up with it for now until it's fixed upstream.
We didn't update the tfstate, just ran terraform apply.
@landintrees Thanks for taking the time to open this issue. I believe this issue should be resolved by a roll back in the breaking change on Azure's side as noted in https://github.com/hashicorp/terraform-provider-azurerm/pull/24817#issuecomment-1984970946. As such I am going to close this issue, if you find that is not the case, please reach out and we can reopen.
@rcskosir I updated my ARM version to latest and I am still seeing this issue. I am not sure that whatever they rolled back corrected it.
@rcskosir I updated my ARM version to latest and I am still seeing this issue. I am not sure that whatever they rolled back corrected it.
I see the same error using Bicep version 0.26.54
The issue is still there
same here
We are still experiencing this on creates. Seems fine on updates.
Still experiencing this issue. Keep seeing changes on _id index even though there are no changes being made on apply.
I can reopen this issue since the behavior seems to still be occurring. @wuxu92 Are you able to provide any insight here on why this does not appear to be fixed by the roll back mentioned in https://github.com/hashicorp/terraform-provider-azurerm/pull/24817#issuecomment-1984970946?
We also keep seeing changes while no changes are being made. Besides the clutter, this is for us causing apply executions while they are not required.
We are seeing the same as @BosBer
Is there an existing issue for this?
Community Note
Terraform Version
1.5.4
AzureRM Provider Version
3.91.0
Affected Resource(s)/Data Source(s)
azurerm_cosmosdb_mongo_collection
Terraform Configuration Files
Debug Output/Panic Output
Expected Behaviour
Collection should be created successfully OR the docs should be updated so that unique=true is not required for indexes with _id key.
Actual Behaviour
Fails with error: Code="BadRequest" Message="The field 'unique' is not valid for _id index specification."
Steps to Reproduce
terraform apply
Important Factoids
We were able to create the collection by removing unique = true from the _id index. When added back in and re-running terraform apply there were no changes.
This is on version 3.6 of cosmos DB.
References
No response