英文:
How can I create an Azure CosmosDB Serverless using Terraform?
问题
我一直在尝试使用Terraform创建无服务器的Azure Cosmos DB数据库,但一直无法成功。
在阅读了Microsoft的文档和Azurerm Terraform注册表文档后,我能够编写以下资源:
resource "azurerm_cosmosdb_account" "resume-challenge-cosmosdb" {
name = var.cosmosdb-name
location = var.region
resource_group_name = azurerm_resource_group.cloud-resume-rg.name
offer_type = "Standard"
kind = "GlobalDocumentDB"
enable_automatic_failover = false
enable_free_tier = true
consistency_policy {
consistency_level = "BoundedStaleness"
max_interval_in_seconds = 300
max_staleness_prefix = 100000
}
geo_location {
location = "brazilsouth"
failover_priority = 0
}
}
但它创建的是普通版本的Cosmos DB。
英文:
I've been trying to create the serverless offer of the cosmosdb database using Terraform, but haven't been able to do so.
After reading Microsoft's documentations and the Azurerm terraform registry documentations, I could code this resource:
resource "azurerm_cosmosdb_account" "resume-challenge-cosmosdb" {
name = var.cosmosdb-name
location = var.region
resource_group_name = azurerm_resource_group.cloud-resume-rg.name
offer_type = "Standard"
kind = "GlobalDocumentDB"
enable_automatic_failover = false
enable_free_tier = true
consistency_policy {
consistency_level = "BoundedStaleness"
max_interval_in_seconds = 300
max_staleness_prefix = 100000
}
geo_location {
location = "brazilsouth"
failover_priority = 0
}
}
but it creates the regular version of the cosmosdb.
答案1
得分: 1
要使 CosmosDB 帐户在使用 AzureRM Terraform 提供程序时变成无服务器模式,您需要在 azurerm_cosmosdb_account
上启用 EnableServerless
功能。为此,您必须添加一个 capabilities
块,并设置 name = "EnableServerless"
。将此应用于您上面的示例如下所示:
resource "azurerm_cosmosdb_account" "resume-challenge-cosmosdb" {
name = var.cosmosdb-name
location = var.region
resource_group_name = azurerm_resource_group.cloud-resume-rg.name
offer_type = "Standard"
kind = "GlobalDocumentDB"
enable_automatic_failover = false
enable_free_tier = true
consistency_policy {
consistency_level = "BoundedStaleness"
max_interval_in_seconds = 300
max_staleness_prefix = 100000
}
geo_location {
location = "brazilsouth"
failover_priority = 0
}
capabilities {
name = "EnableServerless"
}
}
我是根据在 azurerm_cosmosdb_account 资源文档上搜索 "serverless" 这个词来找到这个信息的。
英文:
To make a CosmosDB account serverless using the AzureRM Terraform provider you need to enable the EnableServerless
capability on the azurerm_cosmosdb_account
. To do this you must add a capabilities
block with name = "EnableServerless"
. Applying this to your above example would look like so:
resource "azurerm_cosmosdb_account" "resume-challenge-cosmosdb" {
name = var.cosmosdb-name
location = var.region
resource_group_name = azurerm_resource_group.cloud-resume-rg.name
offer_type = "Standard"
kind = "GlobalDocumentDB"
enable_automatic_failover = false
enable_free_tier = true
consistency_policy {
consistency_level = "BoundedStaleness"
max_interval_in_seconds = 300
max_staleness_prefix = 100000
}
geo_location {
location = "brazilsouth"
failover_priority = 0
}
capabilities {
name = "EnableServerless"
}
}
I found this by searching for the word "serverless" on the azurerm_cosmosdb_account resource docs.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论