A developer is building a serverless payment processing application. The application uses an Amazon SQS queue to trigger an AWS Lambda function. The Lambda function must connect to an Amazon RDS database residing in a private VPC subnet and also call an external payment gateway API over the internet. The Lambda function has a timeout of seconds. Which two configuration steps must the developer perform to ensure reliable processing and correct connectivity? (Select two.)
- Associate the Lambda function with the private subnets of the VPC, and route outbound internet traffic from these subnets to a NAT Gateway in a public subnet.Answer
- Configure the SQS queue's visibility timeout to be at least times the timeout of the Lambda function to prevent duplicate message processing.Answer
- CDeploy the Lambda function in public subnets of the VPC to grant it direct access to both the internal database and the external payment API.
- DSet the SQS queue's visibility timeout to a value less than the Lambda function's timeout to ensure failed messages are retried immediately.
- EConfigure the database client initialization code inside the Lambda handler function block to ensure that database connections are terminated immediately when the handler execution finishes.
Answer
The developer must associate the Lambda function with the private subnets of the VPC, routing internet-bound traffic through a NAT Gateway in a public subnet, and configure the SQS queue's visibility timeout to at least 6 times the Lambda function's timeout.
To securely connect to a database within a private VPC and also make outbound calls to an external payment API, the Lambda function must be associated with the private subnets of the VPC. The private subnets must then route outbound internet traffic through a NAT Gateway located in a public subnet. Additionally, when integration with Amazon SQS is used, the visibility timeout of the queue must be configured to at least 6 times the timeout of the Lambda function. This safety margin prevents other consumers from picking up a message while the Lambda function is still processing it.
Step-by-Step Solution
Key Concept
AWS Lambda VPC networking and Amazon SQS event source mapping timeout configurations.
Estimated Time:2m 0s