A developer is deploying an AWS Lambda function inside a private subnet of a Virtual Private Cloud (VPC) to access an Amazon RDS database. The Lambda function also needs to connect to an external payment processor's public API over the internet. Which configuration should the developer use to allow the Lambda function to access the internet?
- Configure a NAT Gateway in a public subnet, and add a route in the private subnet's route table that directs internet-bound traffic to the NAT Gateway.Answer
- BConfigure the Lambda function to run inside the private subnet without configuring a NAT Gateway or VPC endpoints, assuming the default subnet routing allows outbound internet traffic.
- CModify the IAM execution role's trust policy of the Lambda function to permit direct public internet connections to external IP ranges.
- DStore the payment processor's API key in AWS Systems Manager Parameter Store and enable automatic rotation to open an internet-bound route.
Answer
Configure a NAT Gateway in a public subnet, and add a route in the private subnet's route table that directs internet-bound traffic to the NAT Gateway.
The correct option correctly states that a NAT Gateway must be configured in a public subnet and the private subnet's route table updated to direct destination traffic to the NAT Gateway. This allows Lambda functions inside the private subnet to establish outbound connections to the internet without exposing them to inbound internet traffic.
Step-by-Step Solution
Key Concept
VPC Routing and NAT Gateway for private subnet resources
Estimated Time:1m 0s