A developer is configuring an AWS Lambda function inside a private subnet of a VPC. The Lambda function needs to read messages from an Amazon SQS queue and write records to an Amazon ElastiCache for Redis cluster located in another private subnet within the same VPC. The Lambda function is successfully writing to ElastiCache but is unable to connect to the Amazon SQS service. Which configuration change should the developer make to resolve this connectivity issue in the most secure manner?
- AModify the IAM trust policy of the Lambda function's execution role to include the Amazon SQS service principal (sqs.amazonaws.com) as a trusted entity.
- BMove the Lambda function to a public subnet within the VPC to allow it to communicate directly with the public Amazon SQS endpoints.
- Create an interface VPC endpoint for Amazon SQS in the VPC, and update the security groups to allow traffic between the Lambda function and the endpoint.Cevap
- DStore the SQS queue URL in AWS Secrets Manager, and configure the Lambda function to retrieve it using the Secrets Manager API to bypass the network route.
Cevap
Create an interface VPC endpoint for Amazon SQS in the VPC, and update the security groups to allow traffic between the Lambda function and the endpoint.
Creating an interface VPC endpoint (powered by AWS PrivateLink) for Amazon SQS allows resources in private subnets to communicate privately with the service without traversing the public internet or needing a NAT Gateway. Since the Lambda function is in a private subnet, it can route SQS traffic through this private endpoint.
Adım Adım Çözüm
Anahtar Kavram
Establishing private connectivity to public AWS services from within a VPC using Interface VPC Endpoints (AWS PrivateLink).
Tahmini Süre:1m 30s