azure - 无法使用 terraform 在 cosmos db 中设置自动缩放
问题描述
我正在尝试将自动缩放设置添加到 cosmos db,但它不允许 shard_key 值为 null。因为现在我们没有 shard_key 但仍想使用自动缩放功能。我可以在 azure 门户中看到,当我在门户中导入没有 shard_key 创建的资源时,该值显示为空,但在创建时我无法做到这一点。
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
}
}
解决方案
我在我的环境中对其进行了测试,使用 terraform 无法设置没有分片键的自动缩放设置。
错误:
当我在 Shard_key 中添加一些值时,它会成功。
来自 Terraform 文档:
autoscale_settings - (可选)如下定义的 autoscale_settings 块。这必须在创建数据库时设置,否则在没有手动 terraform destroy-apply 的情况下无法更新。需要设置 shard_key。
根据上述内容,必须设置 Shard_key 值以使用 terraform 添加自动缩放设置。
对于替代解决方案,您必须使用 ARM_template/Bicep/Portal。您可以参考以下链接以获取相同的模板。
参考:
推荐阅读
- r - R问题:如何计算多列的平均值并选择要保存在数据集中的变量
- java - 教我为什么此代码无法检查我的输入是否为 int,以及如何修复它
- mysql - 将 SQL 查询转换为具有多个表的 sequelize 查询
- go - 如果数组作为 &val 传入,然后转换为 interface{},则更新数组元素
- c# - 应用程序中 WM_TOUCH 和 WM_GESTURE 的 TUIO 触摸事件
- c# - 如何使用 autofac 通过字符串解析具有 3rd 方通用接口的类
- c# - C# 将对象转换为图像
- audio-streaming - 使用 NAudio 和 Vorbis 直播音频文件
- amazon-web-services - 如何将策略分配给 AWS 资源?
- mysql - 带有 Kotlin 暴露错误的 MySQL 连接表:“没有匹配的主/外键对”