A developer is configuring an AWS Lambda function that processes user session data. The function needs to connect to an Amazon ElastiCache for Redis cluster running in private subnets within a VPC. Additionally, the function must retrieve an API key stored in AWS Secrets Manager to authenticate calls to an external third-party service. The developer deploys the Lambda function inside the same private subnets of the VPC to ensure connectivity to the Redis cluster. However, during testing, the function fails to connect to AWS Secrets Manager and timeouts when attempting to invoke the external third-party API. Which two actions should the developer take to resolve these connectivity issues? (Select two.)
- Configure a NAT Gateway in a public subnet of the VPC, and add a route in the private subnets' route table directing traffic to the NAT Gateway.Answer
- Create an Interface VPC Endpoint (AWS PrivateLink) for AWS Secrets Manager in the private subnets, and configure the security groups to allow traffic between the Lambda function and the endpoint.Answer
- CCreate a Gateway VPC Endpoint for AWS Secrets Manager, and associate it with the route tables of the private subnets where the Lambda function is deployed.
- DMove the Lambda function to the public subnets of the VPC and enable the public IP address setting in the function's VPC configuration.
- EConfigure AWS Systems Manager Parameter Store using local environment variables to store the secret keys to avoid external network calls.
Answer
To resolve the connectivity issues, the developer must configure a NAT Gateway in a public subnet of the VPC and route internet-bound traffic from the private subnets to it, allowing the Lambda function to reach the external third-party API. Additionally, the developer should create an Interface VPC Endpoint for AWS Secrets Manager in the VPC so the Lambda function can privately access Secrets Manager without traversing the public internet.
The correct solution involves two steps: first, configuring a NAT Gateway in a public subnet of the VPC and adding a default route () in the private subnet route table to allow the Lambda function to reach the external API. Second, creating an Interface VPC Endpoint (AWS PrivateLink) for AWS Secrets Manager inside the VPC allows private communication with the Secrets Manager service without needing to go over the public internet, satisfying security and architectural requirements.
Step-by-Step Solution
Key Concept
Configuring VPC networking for AWS Lambda functions requiring both private VPC resource access and external internet/AWS service connectivity.