【问题标题】:unable to set autoscale in cosmos db using terraform无法使用 terraform 在 cosmos db 中设置自动缩放
【发布时间】:2021-11-06 01:03:18
【问题描述】:

我正在尝试将自动缩放设置添加到 cosmos db,但它不允许 shard_key 值为 null。因为现在我们没有 shard_key 但仍想使用自动缩放功能。我可以在 azure 门户中看到,当我在门户中导入没有 shard_key 创建的资源时,该值显示为 null,但在创建时我无法做到。

resource "azurerm_cosmosdb_mongo_collection" "collections" {

  name                = "dbCollName"
  resource_group_name = azurerm_cosmosdb_account.cosmosdb.resource_group_name
  account_name        = local.account_name
  database_name       = "dbName"
  shard_key           = null

  autoscale_settings = {
          max_throughput = 4000
  }
 
}

【问题讨论】:

  • 你只能创建一个没有分片键的固定大小的集合。如果您计划需要扩展此集合,则需要在创建它之前决定一个分片键,因为一旦创建它就无法更改它。
  • Azure 门户和 ARM 模板允许对高达 10K RU 的非分片集合进行自动缩放。虽然我现在了解分片键的重要性,但我们在应用中没有它

标签: azure azure-cosmosdb terraform-provider-azure


【解决方案1】:

我在我的环境中对其进行了测试,使用 terraform 无法设置没有分片键的自动缩放设置。

错误:

当我在 Shard_key 中添加一些值时,它会成功。

来自 Terraform 文档:

autoscale_settings - (可选)定义的 autoscale_settings 块 以下。这必须在创建数据库时设置,否则不能 在没有手动 terraform destroy-apply 的情况下更新。需要 shard_key 设置。

根据上述,必须设置 Shard_key 值以使用 terraform 添加自动缩放设置。

对于替代解决方案,您必须使用 ARM_template/Bicep/Portal。您可以参考以下链接以获取相同的模板。

参考:

Azure-QuickStart-Templates

【讨论】:

    猜你喜欢
    • 2020-07-31
    • 2019-06-22
    • 2021-04-12
    • 2018-07-14
    • 1970-01-01
    • 1970-01-01
    • 2019-10-21
    • 2021-06-19
    • 2019-08-16
    相关资源
    最近更新 更多