Created
November 30, 2018 14:41
-
-
Save himlohiya/c76c5471bb72090e6fcdc211f3c010a3 to your computer and use it in GitHub Desktop.
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
# nat gw | |
resource "aws_eip" "nat" { | |
vpc = true | |
} | |
resource "aws_nat_gateway" "nat-gw" { | |
allocation_id = "${aws_eip.nat.id}" | |
subnet_id = "${aws_subnet.main-public-1.id}" | |
depends_on = ["aws_internet_gateway.main-gw"] | |
} | |
# VPC setup for NAT | |
resource "aws_route_table" "main-private" { | |
vpc_id = "${aws_vpc.main.id}" | |
route { | |
cidr_block = "0.0.0.0/0" | |
nat_gateway_id = "${aws_nat_gateway.nat-gw.id}" | |
} | |
tags { | |
Name = "main-private-1" | |
} | |
} | |
# route associations private | |
resource "aws_route_table_association" "main-private-1-a" { | |
subnet_id = "${aws_subnet.main-private-1.id}" | |
route_table_id = "${aws_route_table.main-private.id}" | |
} | |
resource "aws_route_table_association" "main-private-2-a" { | |
subnet_id = "${aws_subnet.main-private-2.id}" | |
route_table_id = "${aws_route_table.main-private.id}" | |
} | |
resource "aws_route_table_association" "main-private-3-a" { | |
subnet_id = "${aws_subnet.main-private-3.id}" | |
route_table_id = "${aws_route_table.main-private.id}" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment