A developer is troubleshooting an AWS Lambda function that is configured to access an Amazon RDS DB instance inside a private subnet of a custom VPC. The function also needs to call an external billing API over the public internet. During testing, the developer observes two issues: the function cannot establish a connection to the external billing API, and the database experiences connection exhaustion due to a high volume of database connections being created during peak traffic. Which two actions should the developer take to resolve these configuration and performance issues? (Select TWO.)
- Configure a NAT Gateway in a public subnet of the VPC and add a route pointing to it in the private subnet's route table.Cevap
- Initialize the database connection client outside of the Lambda handler function to reuse connections across execution contexts.Cevap
- CDeploy the Lambda function in a public subnet and enable the public IP assignment configuration on the function.
- DCreate a Gateway VPC Endpoint for the external billing API and associate it with the private subnet's route table.
- EAdd code inside the Lambda handler to explicitly close the connection and force execution context recycling after every invocation.
Cevap
Configure a NAT Gateway in a public subnet of the VPC, add a route pointing to it in the private subnet's route table, and initialize the database connection client outside of the Lambda handler function.
To enable internet access for a Lambda function in a private VPC subnet, a NAT Gateway must be set up in a public subnet, and the private subnet's route table must route traffic bound for the internet to the NAT Gateway. Additionally, database connection clients should be declared globally outside the handler function to allow reuse of existing connections across subsequent warm executions of the same Lambda container instance.
Adım Adım Çözüm
Anahtar Kavram
VPC Lambda internet access configurations and execution context reuse strategies.