我想编写一个 terraform 模块来创建 dynamoDb 表。这些属性应该从.tfvars默认变量中读取,而不是像此处的.tf资源指南中那样已命名
为了进一步解释,假设使用属性列表来实现此伪代码:
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"
}
}
}
Run Code Online (Sandbox Code Playgroud)
如何在 terraform plan/apply 期间迭代属性列表并创建属性{ } ?属性块的数量不能像 terraform 文档中所示的那样是静态的,并且它们的名称必须从变量中读取。