Skip to content
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 reading or replacing throughput from CosmosDB serverless database #8661

Closed
findemor opened this issue Sep 28, 2020 · 3 comments · Fixed by #8673
Closed

Error reading or replacing throughput from CosmosDB serverless database #8661

findemor opened this issue Sep 28, 2020 · 3 comments · Fixed by #8673

Comments

@findemor
Copy link

Hello. I am trying to create cosmosdb database in a cosmosdb serverless account..
I am using azurerm version = "=2.29.0" with terraform cli v0.13.3.

When we create the terraform plan, it says:

Terraform will perform the following actions:

  # azurerm_cosmosdb_mongo_database.cm_db will be created
  + resource "azurerm_cosmosdb_mongo_database" "cm_db" {
      + account_name        = "dev-db-account-cm-ms-esb-custom"
      + id                  = (known after apply)
      + name                = "dev-cm-db"
      + resource_group_name = "custom-esb-automated-cm"
      + throughput          = (known after apply)
    }

Plan: 1 to add, 0 to change, 0 to destroy.

Pay attention to line " throughput = (known after apply) ". I suppose this is the cause of the error..

When I apply the generated plan I get this error:

Error: Error reading Throughput on Cosmos Mongo Database "dev-cm-db" (Account: "dev-db-account-cm-ms-esb-custom"): documentdb.MongoDBResourcesClient#GetMongoDBDatabaseThroughput: Failure responding to request: StatusCode=400 -- Original Error: autorest/azure: Service returned an error. Status=400 Code="BadRequest" Message="Message: {\"code\":\"BadRequest\",\"message\":\"Reading or replacing offers is not supported for serverless accounts.\\r\\nActivityId: 0c1498ff-e19e-42d3-hidden, Microsoft.Azure.Documents.Common/2.11.0\"}, Request URI: /offers, RequestStats: , SDK: Microsoft.Azure.Documents.Common/2.11.0"

  on main.tf line 97, in resource "azurerm_cosmosdb_mongo_database" "cm_db":
  97: resource "azurerm_cosmosdb_mongo_database" "cm_db" {

I suppose azurerm plugin is trying to read the throughtput value from azure, what is not allowed when using serverless cosmosdb.

Anyone is facing the same problem? Do you know some workaround ?

My cosmosdb terraform code (as you can see, I am not giving any value to troughtput, because doing that is not allowed in serverless -you get a completely different error message- which is logical):

## Data 

resource "random_integer" "ri" {
  min = 10000
  max = 99999
}

### CosmoDB Account
resource "azurerm_cosmosdb_account" "db" {
  name                = var.cm_cosmos_db_account_name
  resource_group_name = azurerm_resource_group.rg.name
  location            = var.cm_location
  offer_type          = "Standard"
  kind                = "MongoDB"
  enable_automatic_failover = true

  capabilities {
    name = "EnableServerless"
  }

  capabilities {
    name = "mongoEnableDocLevelTTL"
  }

  capabilities {
    name = "MongoDBv3.4"
  }

  consistency_policy {
    consistency_level       = "BoundedStaleness"
    max_interval_in_seconds = 10
    max_staleness_prefix    = 200
  }

  geo_location {
    location          = azurerm_resource_group.rg.location
    failover_priority = 0
  }
}

### Database Mongodb
resource "azurerm_cosmosdb_mongo_database" "cm_db" {
  name                = local.cm_db_name
  resource_group_name = azurerm_cosmosdb_account.db.resource_group_name
  account_name        = azurerm_cosmosdb_account.db.name
  depends_on = [azurerm_cosmosdb_account.db]
}

Thank you!

@mariussm
Copy link
Contributor

mariussm commented Oct 9, 2020

Same issue, hoping the linked pull request will be applied soon :)

@ghost
Copy link

ghost commented Nov 5, 2020

This has been released in version 2.35.0 of the provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading. As an example:

provider "azurerm" {
    version = "~> 2.35.0"
}
# ... other configuration ...

@ghost
Copy link

ghost commented Dec 5, 2020

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 👉 [email protected]. Thanks!

@ghost ghost locked as resolved and limited conversation to collaborators Dec 5, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
4 participants