An image processing application uses an Amazon SQS queue to trigger an AWS Lambda function that processes batch metadata and fetches external assets via HTTPS. The Lambda function is placed in a private VPC subnet to securely query an Amazon RDS PostgreSQL DB instance in the same VPC. During testing, the developer observes two issues: the Lambda function fails to connect to the external assets API, and several messages from the SQS queue are being processed multiple times, causing duplicate entries in the database. The Lambda function's timeout is set to minutes. Which two actions should the developer take 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 pointing traffic to the NAT Gateway.Answer
- Increase the visibility timeout of the Amazon SQS queue to at least minutes, matching the recommended ratio of times the Lambda function's timeout.Answer
- CAssign a public IPv4 address to the Lambda function configuration and associate an Internet Gateway directly with the private subnet's route table.
- DIncrease the Lambda function's timeout value to minutes to allow the function more time to process the batch before the queue retrieves the message again.
- EEnable Provisioned Concurrency for the Lambda function and set the execution timeout to match the default SQS visibility timeout of seconds.
Answer
Configure a NAT Gateway in a public subnet of the VPC with a route for in the private subnet's route table, and increase the SQS queue's visibility timeout to at least minutes.
Configuring a NAT Gateway in a public subnet and updating the private subnet's route table ensures that the Lambda function can route outbound HTTPS requests to the internet. Concurrently, increasing the SQS visibility timeout to at least times the Lambda timeout ( minutes for a -minute Lambda timeout) prevents SQS from releasing messages back to the queue while the Lambda function is still processing them, thereby preventing duplicate processing.
Step-by-Step Solution
Key Concept
Configuring private subnet internet access for AWS Lambda and aligning SQS visibility timeouts with Lambda function execution limits.
Estimated Time:2m 0s