Skip to content

Instantly share code, notes, and snippets.

@100daysofdevops
Created February 26, 2019 19:29
Show Gist options
  • Select an option

  • Save 100daysofdevops/4cb1842fb6874333b1b3f555ccdffa2d to your computer and use it in GitHub Desktop.

Select an option

Save 100daysofdevops/4cb1842fb6874333b1b3f555ccdffa2d to your computer and use it in GitHub Desktop.
# Associate Public Subnet with Public Route Table
resource "aws_route_table_association" "public_subnet_assoc" {
count = "${aws_subnet.public_subnet.count}"
route_table_id = "${aws_route_table.public_route.id}"
subnet_id = "${aws_subnet.public_subnet.*.id[count.index]}"
depends_on = ["aws_route_table.public_route", "aws_subnet.public_subnet"]
}
# Associate Private Subnet with Private Route Table
resource "aws_route_table_association" "private_subnet_assoc" {
count = "${aws_subnet.private_subnet.count}"
route_table_id = "${aws_default_route_table.private_route.id}"
subnet_id = "${aws_subnet.private_subnet.*.id[count.index]}"
depends_on = ["aws_default_route_table.private_route", "aws_subnet.private_subnet"]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment