A company is migrating a transaction processing system to AWS. The solution uses an AWS Lambda function that must process events from an Amazon SQS queue, perform a call to an external payment gateway API over the public internet, and save the transaction status to an Amazon DynamoDB table. The Lambda function is configured to run inside private subnets of an Amazon VPC to comply with security requirements. During testing, the function experiences connection timeout errors when trying to reach the payment gateway. Additionally, many SQS messages are being processed multiple times by different Lambda invocations. Which two configuration changes should a developer make to resolve these issues? (Select two.)
- Configure a NAT Gateway in a public subnet of the VPC, and add a route in the private subnet's route table directing outbound destination 0.0.0.0/0 traffic to the NAT Gateway.Cevap
- Increase the visibility timeout of the Amazon SQS queue to at least 6 times the timeout of the Lambda function.Cevap
- CAttach an Internet Gateway directly to the private subnet where the Lambda function resides, and modify the route table to route 0.0.0.0/0 traffic to it.
- DSet the visibility timeout of the Amazon SQS queue to be equal to or less than the Lambda function timeout to ensure that messages return to the queue immediately if the function fails.
- EAssociate an Elastic IP address directly to the Lambda function's elastic network interface (ENI) to allow direct outbound communication with the external API.
Cevap
To resolve the issues, configure a NAT Gateway in a public subnet of the VPC and route outbound destination 0.0.0.0/0 traffic from the private subnet's route table to the NAT Gateway, and increase the visibility timeout of the Amazon SQS queue to at least 6 times the timeout of the Lambda function.
Configuring a NAT Gateway in a public subnet and routing the private subnet's outbound traffic (0.0.0.0/0) to it enables the Lambda function inside the private subnet to securely access the public internet (external payment gateway). Concurrently, setting the Amazon SQS visibility timeout to at least 6 times the Lambda function timeout satisfies the AWS-recommended integration guidelines, preventing messages from being visible to other pollers before the current invocation completes or has a chance to retry.
Adım Adım Çözüm
Anahtar Kavram
Configuring VPC routing for outbound access in AWS Lambda and adjusting SQS queue visibility timeout relative to Lambda timeouts.