Skip to content

Instantly share code, notes, and snippets.

@khushi20218
Created August 13, 2020 06:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save khushi20218/dd1809631eae4c85582fb64915f358bb to your computer and use it in GitHub Desktop.
Save khushi20218/dd1809631eae4c85582fb64915f358bb to your computer and use it in GitHub Desktop.
# EIP
resource "aws_eip" "tf-eip" {
tags = {
"Name" = "vpc-eip"
}
}
# NAT Gateway
resource "aws_nat_gateway" "tf_ngw" {
allocation_id = aws_eip.tf-eip.id
subnet_id = aws_subnet.pub_subnet1.id
tags = {
"Name" = "tf-ng"
}
}
# NGW Route Table
resource "aws_default_route_table" "tf_ng_route" {
depends_on = [
aws_nat_gateway.tf_ngw
]
default_route_table_id = aws_vpc.tf_vpc.default_route_table_id
route {
cidr_block = "0.0.0.0/0"
gateway_id = aws_nat_gateway.tf_ngw.id
}
tags = {
Name = "tf-ng-route"
}
}
# NGW route association
resource "aws_route_table_association" "tf_ng_assoc" {
subnet_id = aws_subnet.pvt_subnet2.id
route_table_id = aws_default_route_table.tf_ng_route.id
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment