A developer is configuring an AWS Lambda function to run inside private subnets of a custom VPC. The Lambda function needs to read data from an Amazon Aurora PostgreSQL database located in another private subnet of the same VPC. Additionally, the Lambda function must retrieve database credentials from AWS Secrets Manager. To meet security requirements, all traffic must remain within the AWS network. Which two configurations must the developer implement to allow the Lambda function to connect to both the database and AWS Secrets Manager? (Select TWO.)
- Configure the security groups to allow outbound traffic from the Lambda function to the database, and inbound traffic to the database from the Lambda function.Answer
- BDeploy a NAT Gateway in the private subnet, and update the private subnet's route table to route traffic destined for AWS Secrets Manager through the NAT Gateway.
- Create an Interface VPC Endpoint for AWS Secrets Manager in the private subnets, and configure the Lambda function's security group to allow outbound traffic to the endpoint.Answer
- DCreate a Gateway VPC Endpoint for AWS Secrets Manager, and associate it with the route table of the private subnets.
- EAdd a statement to the AWS Secrets Manager resource-based policy to trust the VPC's CIDR block and allow the Lambda service role to assume a trust role for cross-network access.
Answer
Configure the security groups to allow outbound traffic from the Lambda function to the database (and inbound traffic to the database from the Lambda function) and create an Interface VPC Endpoint for AWS Secrets Manager in the private subnets, configuring the Lambda function's security group to allow outbound traffic to the endpoint.
To secure communications between resources, security groups must explicitly allow traffic between the Lambda function and the database. Additionally, because the Lambda function resides in a private VPC subnet and must reach AWS Secrets Manager without using the public internet, an Interface VPC Endpoint must be provisioned. This places an Elastic Network Interface in the private subnet to facilitate private communication with Secrets Manager.
Step-by-Step Solution
Key Concept
AWS VPC private connectivity using Security Groups and Interface VPC Endpoints.