I want to write a terraform module that will create dynamoDb tables. The attributes are expected to be read from .tfvars
or default variable instead of being already named in .tf
as in the resource guide here
To explain further, say a list of attributes is being used to achieve this pseudo-code:
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"
}
}
}
How can I iterate over the attribute list and create the attribute{ } during terraform plan/apply ? The number of attribute blocks cannot be static like shown in the terraform docs, and their names must be read from variables.