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

Support for Cosmos DB serverless #8175

Closed
ablyler opened this issue Aug 19, 2020 · 9 comments · Fixed by #9187 or #9311
Closed

Support for Cosmos DB serverless #8175

ablyler opened this issue Aug 19, 2020 · 9 comments · Fixed by #9187 or #9311

Comments

@ablyler
Copy link

ablyler commented Aug 19, 2020

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Description

Add support for the new serverless version of Cosmos DB. This appears to be enabled by adding EnableServerless to the capabilities property.

New or Affected Resource(s)

  • azurerm_cosmosdb_account

Potential Terraform Configuration

resource "azurerm_cosmosdb_account" "db" {
  name                = "my-cosmos-db"
  location            = "${azurerm_resource_group.rg.location}"
  resource_group_name = "${azurerm_resource_group.rg.name}"
  offer_type          = "Standard"
  kind                    = "GlobalDocumentDB"

  enable_automatic_failover = false
  capabilities        = [{
    name = "EnableServerless"
  }]
}

References

@cwoolum
Copy link

cwoolum commented Aug 21, 2020

I was actually thinking it might be useful as as a different offer_type.

offer_type = "Serverless"

@robinkb
Copy link

robinkb commented Aug 24, 2020

@cwoolum That is not how it currently works in the Azure API, so I don't think that's a good idea. It could cause problems in the future.

I think supporting this would require changes to resources other than azurerm_cosmosdb_account. Provisioning an account in serverless mode will alter the behaviour of more than just the account. See the Cosmos DB Serverless documentation.
https://docs.microsoft.com/en-us/azure/cosmos-db/serverless#using-serverless-resources

Specifically, this part:

Provisioning throughput is not required on serverless containers, so the following statements are applicable:

  • You can't pass any throughput when creating a serverless container and doing so returns an error.
  • You can't read or update the throughput on a serverless container and doing so returns an error.
  • You can't create a shared throughput database in a serverless account and doing so returns an error.

I tried to create a azurerm_cosmosdb_sql_database and azurerm_cosmosdb_sql_container on a Serverless Cosmos DB account that I provisioned using an ARM template. Terraform failed to create these resources because it was making calls that are rejected on a Serverless Cosmos DB account.

@ricohomewood
Copy link

I believe this has been fix as part of 2.29: #8533

@tombuildsstuff
Copy link
Contributor

Closing since this appears to have been fixed by #8553 which shipped as a part of 2.29 yesterday - thanks for the heads up @ricohomewood :)

@piizei
Copy link

piizei commented Sep 25, 2020

Actually it does not work. When you run terraform second time with 2.29 you get this error:

Error: Error reading Throughput on Cosmos SQL Database "xxx" (Account: "xxx") 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: xxx, Microsoft.Azure.Documents.Common/2.11.0"}, Request URI: /offers, RequestStats: , SDK: Microsoft.Azure.Documents.Common/2.11.0"

@robinkb
Copy link

robinkb commented Sep 25, 2020

That is what I was talking about in my earlier comment in this issue. It's not as simple as supporting an additional attribute value. Certain calls to the CosmosDB resources are blocked in Serverless mode because they are no longer relevant.

@tombuildsstuff I really think that this issue needs to be re-opened, because the provider currently doesn't really support Serverless mode. Just passing the capability flag is not enough.

@tombuildsstuff
Copy link
Contributor

Re-opening since there's some more to do here

@liyubupt
Copy link

Supporting serverless would introduce really big benefit for our project. and would be excited to see this is fixed soon 👍

@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.