An e-commerce application's user onboarding workflow relies on an AWS Lambda function. The function is placed inside a private subnet of a custom VPC to securely query an Amazon Aurora PostgreSQL database. During a high-traffic promotional campaign, the application experiences two issues: the function fails to establish database connections because the database's maximum connection limit is exceeded, and it cannot connect to an external third-party identity verification API, resulting in network connection timeouts. Which two configuration modifications will resolve these issues?
- Configure the route table of the private subnets where the Lambda function is deployed to route outbound traffic () to a NAT Gateway located in a public subnet.Answer
- Create an Amazon RDS Proxy for the Aurora database and update the Lambda function's database connection string to use the proxy endpoint.Answer
- CDeploy the Lambda function in public subnets of the VPC and assign a public IP address to allow direct outbound communication.
- DInitialize the database connection pool inside the Lambda handler function to guarantee that connections are closed when the execution terminates.
- ECreate a VPC Gateway Endpoint in the route table of the Lambda function's subnets to establish a private route to the external identity verification API.
Answer
To resolve the issues, the developer must configure the route table of the private subnets to route outbound traffic through a NAT Gateway located in a public subnet, and create an Amazon RDS Proxy for the database while updating the function's connection string to use the proxy endpoint.
Configuring a NAT Gateway in a public subnet and routing all outbound internet traffic from the private subnets to it allows the Lambda function to securely reach external APIs. Creating an Amazon RDS Proxy pools database connections, preventing the function from exhausting Aurora's connection pool as it scales horizontally.
Step-by-Step Solution
Key Concept
AWS Lambda VPC networking configuration and RDS database connection management
Estimated Time:2m 30s