Last active
October 12, 2016 10:17
-
-
Save brikis98/0af6b4f1a3467e5341c6569d2a878749 to your computer and use it in GitHub Desktop.
Conditionals with inline attributes in Terraform
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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