Which solution will provide the EC2 instances in the private subnet with access to the internet?
Create a NAT gateway in the public subnet. Create a route from the private subnet to the NAT gateway.
Create a NAT gateway in the public subnet. Create a route from the public subnet to the NAT gateway.
Create a NAT gateway in the private subnet. Create a route from the public subnet to the NAT gateway.
Create a NAT gateway in the private subnet. Create a route from the private subnet to the NAT gateway.
Explanations:
A NAT gateway in the public subnet allows instances in the private subnet to access the internet by routing outbound traffic through the NAT gateway. The private subnet must have a route table entry pointing to the NAT gateway for internet access.
A route from the public subnet to the NAT gateway does not enable instances in the private subnet to access the internet. Instances in the public subnet do not need NAT gateways for internet access as they can access the internet directly.
A NAT gateway must be located in a public subnet to function correctly. Creating a NAT gateway in the private subnet would not allow it to communicate with the internet, rendering it useless for providing internet access to private instances.
Similar to option C, a NAT gateway in the private subnet cannot route internet traffic. Instances in the private subnet would need a route to a NAT gateway in a public subnet to access the internet.