amazon-web-servicesterraformamazon-vpcaws-nat-gateway

Is it possible to to configure NAT Gateway without using Internet Gateway with Terraform


This is my code:

enter image description here

enter image description here

Is it possible to to configure NAT Gateway without using Internet Gateway with Terraform?

The code which I wrote for deploying the cod with terraform but I keep getting this issue:

enter image description here

This is the error I get:


Solution

  • Is it possible? Yes. Is it what you need? It depends on what the purpose of your NAT Gateway is.

    The AWS NAT Gateways documentation explains that there are two different types of NAT Gateways:

    1. Public NAT Gateways which are meant to route traffic from (and optionally, to) your private subnets to the internet.
    2. Private gateways which are for routing traffic between your private subnets and transit gateway or a virtual private gateway.

    For private gateways you don't need an Internet Gateway. With Terraform, you can create a private gateway by adding the connectivity_type: "private" argument to your aws_nat_gateway.

    However, for public gateways, you do need an Internet Gateway. If you didn't have one, how else would you route traffic to the internet?