A developer is implementing a microservice using an AWS Lambda function that retrieves database credentials from AWS Secrets Manager and then connects to an Amazon RDS PostgreSQL database. The RDS database is hosted in private subnets within a VPC. To secure the database connection, the developer configures the Lambda function to run inside the same VPC and private subnets. However, during testing, the Lambda function execution times out during the SDK client initialization and call to Secrets Manager.
Which configuration change should the developer implement to resolve this issue while maintaining the most secure architecture?
- Configure an Interface VPC Endpoint (AWS PrivateLink) for AWS Secrets Manager within the private subnets, and configure the security groups to allow HTTPS traffic from the Lambda function to the endpoint.Answer
- BModify the Lambda function configuration to associate it with public subnets and enable public IP address assignment to allow it to communicate directly with the public endpoint of AWS Secrets Manager.
- CUpdate the trust policy of the Lambda function's IAM execution role to trust the AWS Secrets Manager service principal (secretsmanager.amazonaws.com), allowing it to push credentials to the execution environment.
- DMigrate the database credentials from AWS Secrets Manager to the AWS Systems Manager Parameter Store as a SecureString, since Parameter Store is natively accessible within private subnets without additional routing configurations.
Answer
Configure an Interface VPC Endpoint (AWS PrivateLink) for AWS Secrets Manager within the private subnets, and configure the security groups to allow HTTPS traffic from the Lambda function to the endpoint.
The correct configuration is to create an Interface VPC Endpoint (AWS PrivateLink) for AWS Secrets Manager in the private subnets. This registers Elastic Network Interfaces (ENIs) with private IP addresses in the VPC subnets that route traffic directly to AWS Secrets Manager over the AWS internal network. By allowing outbound HTTPS (port ) from the Lambda function's security group to the VPC endpoint's security group, the Lambda function can resolve the endpoint privately and securely retrieve the database credentials.
Step-by-Step Solution
Key Concept
VPC Endpoints (AWS PrivateLink) enable private connectivity between VPC resources and supported AWS services without internet traversal.
Estimated Time:2m 0s