A developer is configuring an AWS Lambda function to process customer registration events. The function must query an Amazon RDS MySQL database located in private VPC subnets. The database credentials are securely stored in AWS Secrets Manager. The developer wants to ensure the Lambda function can securely access the secret and connect to the database efficiently without causing database connection exhaustion or network timeouts. Which of the following configurations should the developer implement to meet these requirements? (Select TWO.)
- Initialize the database connection pool outside of the Lambda handler function to enable connection reuse across multiple invocations.Cevap
- Associate the Lambda function with the private subnets of the VPC, and configure an interface VPC endpoint (AWS PrivateLink) for Secrets Manager in the VPC.Cevap
- CAssociate the Lambda function with a public subnet of the VPC and enable public IP assignment to allow direct communication with the Secrets Manager public endpoint.
- DRe-create and close the database connection inside the Lambda handler function on every invocation to prevent connection pool exhaustion.
- EModify the trust policy of the Lambda function's execution role to grant permission for the secretsmanager:GetSecretValue action on the secret resource.
Cevap
To optimize database connection handling and ensure secure, private network access, the developer should initialize the database connection pool outside of the Lambda handler function, and associate the Lambda function with the private VPC subnets while configuring an interface VPC endpoint (AWS PrivateLink) for Secrets Manager.
Initializing the database connection pool outside the Lambda handler function leverages execution context reuse, enabling subsequent warm invocations to share the active connection pool. Additionally, associating the function with private subnets enables connectivity to the RDS instance, while configuring an interface VPC endpoint for Secrets Manager provides a secure, private route to fetch secrets without routing requests through the public internet.
Adım Adım Çözüm
Anahtar Kavram
AWS Lambda VPC networking, execution context reuse, and AWS Secrets Manager integration.