我想编写一个 terraform 模块来创建 dynamoDb 表。这些属性应该是从.tfvars
默认变量中读取的,而不是已经.tf
在资源指南中命名为here
为了进一步解释,假设正在使用属性列表来实现此伪代码:
resource "aws_dynamodb_table" "basic-dynamodb-table" {
name = "GameScores"
... #Other required feilds
...
...
# attributes is a list of names
for(attribute_name:${length(var.attributes)}){
attribute {
name = "${var.attributes[i]}"
type = "N"
}
}
}
如何在 terraform plan/apply 期间遍历属性列表并创建属性{}?属性块的数量不能像 terraform 文档中显示的那样是静态的,并且它们的名称必须从变量中读取。