Add support for the new serverless version of Cosmos DB. This appears to be enabled by adding EnableServerless
to the capabilities
property.
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"
}]
}
I was actually thinking it might be useful as as a different offer_type
.
offer_type = "Serverless"
@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.
I believe this has been fix as part of 2.29: https://github.com/terraform-providers/terraform-provider-azurerm/pull/8533
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 :)
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"
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.
Re-opening since there's some more to do here
Supporting serverless would introduce really big benefit for our project. and would be excited to see this is fixed soon ๐
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!
Most helpful comment
Re-opening since there's some more to do here