Skip to content

Instantly share code, notes, and snippets.

@himlohiya
Created November 30, 2018 14:41
Show Gist options
  • Save himlohiya/c76c5471bb72090e6fcdc211f3c010a3 to your computer and use it in GitHub Desktop.
Save himlohiya/c76c5471bb72090e6fcdc211f3c010a3 to your computer and use it in GitHub Desktop.
# 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