Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: enable nat gateway when only private subnets are enabled #206

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

wadhah101
Copy link

what

  • Enabled Nat gateway creation when the module does not create public IPs
  • Linked the nat gateway with the private subnet instead

why

  • The default resource of Nat gateway will fail if public_subnets_enabled=false due to it using the first public subnet by default

references

@wadhah101 wadhah101 requested review from a team as code owners April 21, 2024 12:10
@mergify mergify bot added the triage Needs triage label Apr 21, 2024
@joe-niland
Copy link
Member

Hi @wadhah101 just confirming - what use case are you solving here?

@wadhah101
Copy link
Author

wadhah101 commented Apr 22, 2024

Hi @joe-niland
this for the case when

module "subnetprv" {
  source  = "cloudposse/dynamic-subnets/aws"
  version = "2.4.2"

  vpc_id          = module.vpc.vpc_id
  igw_id          = [module.vpc.igw_id]
  ipv4_cidr_block = ["10.10.1.0/24"]

  public_route_table_enabled             = false
  public_open_network_acl_enabled        = false
  ipv4_public_instance_hostnames_enabled = false

  nat_gateway_enabled = true
  public_subnets_enabled  = false
  private_subnets_enabled = true  # the issue is when only private subnets are enabled

  metadata_http_endpoint_enabled = true
  availability_zones             = data.aws_availability_zones.available.names

  context = module.label.context
}

The module will crash when trying to create the nat_gateway, because it's hardcoded to use the public subnets only.
But the gateway default config says it should be enabled even for when we only have private subnets.

Screenshot 2024-04-22 at 09 54 32

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
triage Needs triage
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants