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

azurerm_cosmosdb_sql_database doesn't call get throughput api when cosmos account is serverless #9187

Merged
merged 1 commit into from
Nov 10, 2020

Conversation

ilmax
Copy link
Contributor

@ilmax ilmax commented Nov 6, 2020

Fixes #8175

This is based on #8673 /cc @yupwei68

make testacc TEST=./azurerm/internal/services/cosmos TESTARGS='-run=TestAccAzureRMCosmosDbSqlDatabase' TESTTIMEOUT='60m'

=== RUN   TestAccAzureRMCosmosDbSqlDatabase_basic
=== PAUSE TestAccAzureRMCosmosDbSqlDatabase_basic
=== RUN   TestAccAzureRMCosmosDbSqlDatabase_update
=== PAUSE TestAccAzureRMCosmosDbSqlDatabase_update
=== RUN   TestAccAzureRMCosmosDbSqlDatabase_autoscale
=== PAUSE TestAccAzureRMCosmosDbSqlDatabase_autoscale
=== RUN   TestAccAzureRMCosmosDbSqlDatabase_serverless
=== PAUSE TestAccAzureRMCosmosDbSqlDatabase_serverless
=== CONT  TestAccAzureRMCosmosDbSqlDatabase_basic
=== CONT  TestAccAzureRMCosmosDbSqlDatabase_serverless
=== CONT  TestAccAzureRMCosmosDbSqlDatabase_autoscale
=== CONT  TestAccAzureRMCosmosDbSqlDatabase_update
--- PASS: TestAccAzureRMCosmosDbSqlDatabase_basic (1454.09s)
--- PASS: TestAccAzureRMCosmosDbSqlDatabase_serverless (1515.23s)
--- PASS: TestAccAzureRMCosmosDbSqlDatabase_autoscale (1697.47s)
--- PASS: TestAccAzureRMCosmosDbSqlDatabase_update (1721.92s)
PASS
ok      github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/cosmos      1722.021s

@ghost ghost added the size/M label Nov 6, 2020
@mariussm
Copy link
Contributor

mariussm commented Nov 6, 2020

Awesome, greatly needed. I guess this will fix the following error that happens for Cosmos SQL:

Error: Error reading Throughput on Cosmos SQL Database "--snip--" (Account: "--snip--") ID: documentdb.SQLResourcesClient#GetSQLDatabaseThroughput: 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: c5fe135d-2c40-4f04-a3b6-9b9368c29436, Microsoft.Azure.Documents.Common/2.11.0"}, Request URI: /offers, RequestStats: , SDK: Microsoft.Azure.Documents.Common/2.11.0"

resource "azurerm_cosmosdb_account" "db" {
  name                = "${var.prefix}-${var.environment}-cosmosdb-${var.suffix}"
  location            = azurerm_resource_group.rg.location
  resource_group_name = azurerm_resource_group.rg.name
  offer_type          = "Standard"
  kind                = "GlobalDocumentDB"

  enable_automatic_failover = true

  capabilities {
    name = "EnableServerless"
  }

  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
  }
}

resource "azurerm_cosmosdb_sql_database" "db" {
  name                = "${var.prefix}-${var.environment}-cosmossql-${var.suffix}"
  resource_group_name = azurerm_cosmosdb_account.db.resource_group_name
  account_name        = azurerm_cosmosdb_account.db.name
}

@ilmax
Copy link
Contributor Author

ilmax commented Nov 6, 2020

@mariussm yep, this is aimed at fixing exactly that

@ilmax
Copy link
Contributor Author

ilmax commented Nov 10, 2020

Hey @tombuildsstuff is there something I can do to move this one forward?

Copy link
Member

@jackofallops jackofallops left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @ilmax
Thanks for replicating the changes for the SQL resource. This LGTM 👍. I've got the acceptance tests running at the moment, so assuming they pass we'll get this merged.

@jackofallops
Copy link
Member

Tests passing:
image

@jackofallops jackofallops merged commit 0dc4f49 into hashicorp:master Nov 10, 2020
jackofallops added a commit that referenced this pull request Nov 10, 2020
@ilmax ilmax deleted the fix-cosmosdb-sql-serverless branch November 11, 2020 08:27
@ghost
Copy link

ghost commented Nov 12, 2020

This has been released in version 2.36.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.36.0"
}
# ... other configuration ...

@ghost
Copy link

ghost commented Dec 11, 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 11, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support for Cosmos DB serverless
4 participants