-
Notifications
You must be signed in to change notification settings - Fork 4.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error on Terraform Apply: CosmosDB account name already exists #3813
Comments
I want to add that the error reported occurs the second time you run terraform apply. The first time you get an error like this:
Then if you run terraform apply you get the error orginally report about importing the resource. Checking the Azure portal, CLI, and API calls does not show the name anywhere. I'm not sure this is a terraform issue. It seems that the Azure API starts to create the cosmosDB account, reserves the name, then fails. After that the name is reserved but not attached to your Azure subscription so you can't recover the name. You can't even try to use the name through the portal after it fails in terraform. Maybe there is a bug with how the azurerm terraform provider calls the Azure API but I also feel Azure should not allow this behavior. There is probably a DoS exploit which can be carried out with this bug. |
- Apparently Azure stuff is all-too-fragile and I had to create both Cosmos DB and PostgreSQL twice. - See: hashicorp/terraform-provider-azurerm#3813
- Apparently Azure stuff is all-too-fragile and I had to create both Cosmos DB and PostgreSQL twice. - See: hashicorp/terraform-provider-azurerm#3813
We're getting this error on the first attempt to create the db. We even tried using a GUID as the name and got this error. |
@dhsass @khaljimbo Several people at my company have run in to this and discovered that if you reuse the account name for the geo_location prefix, this is what is causing the issue. 2 solutions to this: #1. Remove the prefix altogether (this will just make the Azure API auto generate one for you) #2. Follow the updated method on the Terraform documentation page, particularly: Hope this fixes it for you! |
I still get the same errors all the time. But whenever i only use one location, it says there is nothing available although i use one which is "recommened" in the Azure portal when i use a failover location it says: Code="BadRequest" Message="Cannot add additional regions, since database account provision failed |
I´m stupid i used location names (like East Us) instead of location ids (like eastus) ... |
👋 Taking a look through I believe @jnunham's comment above should resolve this - as such I'm going to close this issue for the moment Thanks! |
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. If you feel I made an error 🤖 🙉 , please reach out to my human friends 👉 hashibot-feedback@hashicorp.com. Thanks! |
Community Note
Terraform (and AzureRM Provider) Version
Terraform v0.12.3
Affected Resource(s)
azurerm_cosmosdb_account
Terraform Configuration Files
Expected Behavior
CosmosDB account should be created
Actual Behavior
Error: CosmosDB Account 1239website0918627public already exists, please import the resource via terraform import
on cosmosDBwithMongoDBAPI.tf line 6, in resource "azurerm_cosmosdb_account" "db":
6: resource "azurerm_cosmosdb_account" "db" {
Steps to Reproduce
Use simple terraform to create a cosmos DB account. No matter how many random characters are used to create a CosmosDB account it complains that the name already exists.
terraform apply
References
I found issue #3739 which suggests this is fixed in version 1.31 of the azure provider but I am still seeing this error.
The text was updated successfully, but these errors were encountered: