Soru

Zorluk: OrtaServerless Development with AWS Lambda

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 1010 seconds. Which two configuration steps must the developer perform to ensure reliable processing and correct connectivity? (Select two.)

  1. 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.Cevap
  2. Configure the SQS queue's visibility timeout to be at least 66 times the timeout of the Lambda function to prevent duplicate message processing.Cevap
  3. C
    Deploy the Lambda function in public subnets of the VPC to grant it direct access to both the internal database and the external payment API.
  4. D
    Set the SQS queue's visibility timeout to a value less than the Lambda function's timeout to ensure failed messages are retried immediately.
  5. E
    Configure the database client initialization code inside the Lambda handler function block to ensure that database connections are terminated immediately when the handler execution finishes.

Cevap

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.

Adım Adım Çözüm

1
Determine the network routing requirements for the Lambda function.
The Lambda function needs to be associated with the private VPC subnets to reach the RDS database, and its outbound internet traffic (for the payment API) must be routed via a NAT Gateway in a public subnet.
Lambda functions associated with a VPC do not receive public IP addresses and cannot connect to the internet directly, even if placed in public subnets.
2
Calculate the appropriate SQS visibility timeout based on the Lambda timeout.
The SQS queue's visibility timeout must be set to at least 66 times the Lambda function's timeout (which is at least 6060 seconds for a 1010-second Lambda timeout).
This configuration provides a buffer to prevent messages from becoming visible again and being processed multiple times while the Lambda handler is still executing.

Anahtar Kavram

AWS Lambda VPC networking and Amazon SQS event source mapping timeout configurations.
Tahmini Süre:2m 0s
Bu soruyu puanla