Skip to content

Instantly share code, notes, and snippets.

@pmatsinopoulos
Created August 28, 2023 14:19
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 pmatsinopoulos/e3c6607b8dabbec05f0fa7a95027345e to your computer and use it in GitHub Desktop.
Save pmatsinopoulos/e3c6607b8dabbec05f0fa7a95027345e to your computer and use it in GitHub Desktop.
AWS Private and Public Subnets - nat_gateway.tf
resource "aws_eip" "nat_gateway" {
depends_on = [aws_internet_gateway.private_and_public_subnets]
}
resource "aws_nat_gateway" "private_and_public_subnets" {
connectivity_type = "public"
allocation_id = aws_eip.nat_gateway.id
subnet_id = aws_subnet.subnet_2.id # public subnet
tags = {
Name = local.project
}
# To ensure proper ordering, it is recommended to add an explicit dependency
# on the Internet Gateway for the VPC.
depends_on = [aws_internet_gateway.private_and_public_subnets]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment