A team of developers is deploying a backend processing application. An AWS Lambda function is configured to run inside a private VPC subnet to securely query an Amazon RDS PostgreSQL database located in another private subnet. The function must also download configuration files from Amazon S3 and make HTTP POST requests to an external, third-party payment processing API on the public internet. Which network configuration should the developer implement to enable these connections while minimizing data transfer costs and maintaining a secure architecture?
- Deploy the Lambda function in the private subnets. Create a Gateway VPC Endpoint for Amazon S3, and configure a NAT Gateway in a public subnet to route outbound traffic to the public internet.Answer
- BDeploy the Lambda function in the private subnets. Create an Internet Gateway in the VPC and associate a public IP address with the Lambda function to allow direct access to the public API.
- CDeploy the Lambda function in a public subnet and enable public IP assignment. Configure an Interface VPC Endpoint for Amazon S3 to handle object retrieval.
- DDeploy the Lambda function in the private subnets. Configure an Interface VPC Endpoint for Amazon S3, and create a VPC peering connection to route external API traffic through an on-premises network.
Answer
Deploy the Lambda function in the private subnets, configure a Gateway VPC Endpoint for Amazon S3, and deploy a NAT Gateway in a public subnet to route outbound public internet traffic.
Deploying the Lambda function in private subnets allows it to access the private RDS database securely. Using a Gateway VPC Endpoint for S3 is a cost-effective choice since Gateway Endpoints do not incur hourly or data processing charges, unlike Interface Endpoints. A NAT Gateway deployed in a public subnet is required to route outbound public internet traffic for the Lambda function in the private subnet.
Step-by-Step Solution
Key Concept
VPC networking for AWS Lambda, including NAT Gateway and VPC Endpoints.
Estimated Time:1m 30s