Conditionals with inline attributes in Terraform
resource "aws_dynamodb_table" "one_attribute" { | |
count = "${replace(replace(var.num_attributes, "1", "1"), "/^[^1]$/", 0)}" | |
name = "${var.name}" | |
attribute { | |
name = "${var.first_attribute_name}" | |
type = "${var.first_attribute_type}" | |
} | |
} | |
resource "aws_dynamodb_table" "two_attributes" { | |
count = "${replace(replace(var.num_attributes, "2", "1"), "/^[^2]$/", 0)}" | |
name = "${var.name}" | |
attribute { | |
name = "${var.first_attribute_name}" | |
type = "${var.first_attribute_type}" | |
} | |
attribute { | |
name = "${var.second_attribute_name}" | |
type = "${var.second_attribute_type}" | |
} | |
} | |
resource "aws_dynamodb_table" "three_attributes" { | |
count = "${replace(replace(var.num_attributes, "3", "1"), "/^[^3]$/", 0)}" | |
name = "${var.name}" | |
attribute { | |
name = "${var.first_attribute_name}" | |
type = "${var.first_attribute_type}" | |
} | |
attribute { | |
name = "${var.second_attribute_name}" | |
type = "${var.second_attribute_type}" | |
} | |
attribute { | |
name = "${var.third_attribute_name}" | |
type = "${var.third_attribute_type}" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment