【发布时间】:2019-12-29 04:03:23
【问题描述】:
我正在尝试将几个 dynamodb 表导入到 terraform。我被困在如何动态处理环境之间的全局二级索引上。 每个环境都有一个模块和两个状态文件。
如何使用 count 动态输入这些变量,这些变量会在环境之间变化,
例如,在下面的示例中,有 4 个索引,但对于 prod 帐户中的特定索引,读取容量和写入容量会发生变化,而所有其他变量保持不变。
即last-index对prod和nonprod的读写容量值不同
如何在 terraform 中实现?
模块:
locals {
name = ["xxx-index","xxx-index","xxx-index","xxx-index","last-index"]
write_capacity = [ 5,5,5,5,5]
read_capacity = [ 5,5,5,5,5]
range_key = ["xxx","xxx","xxx","xxx","xxx"]
}
global_secondary_index {
count = "${length(local.name)}"
name = "${element(local.name, count.index)}"
write_capacity = "${element(local.write_capacity, count.index)"
read_capacity = "${element(local.read_capacity, count.index)"
hash_key = "userId"
range_key = "${element(local.range_key,count.index)}"
projection_type = "ALL"
}
Terraform -版本 Terraform v0.11.13 + provider.aws v2.25.0
【问题讨论】:
标签: amazon-dynamodb terraform terraform-provider-aws