Soru

Zorluk: ZorServerless Development with AWS Lambda

A developer is implementing an AWS Lambda function that needs to query an Amazon RDS PostgreSQL database located in a private VPC subnet. The function must also make outbound HTTP POST requests to an external API on the public internet, and trace all downstream database queries using AWS X-Ray.

Which two configurations are required to meet these requirements? (Select two.)

  1. Configure the Lambda function to run inside the private subnets of the VPC, and route internet-bound traffic through a NAT Gateway located in a public subnet.Cevap
  2. Enable active tracing on the Lambda function configuration, and use the AWS X-Ray SDK to instrument the database client in the function code.Cevap
  3. C
    Deploy the Lambda function in the public subnets of the VPC to allow both direct access to the database via local routing and direct public internet access through the Internet Gateway.
  4. D
    Modify the Lambda function's IAM execution role trust policy to allow the RDS database service principal to assume the role.
  5. E
    Enable active tracing on the Lambda function to automatically trace database queries without codebase modifications.

Cevap

The Lambda function must be configured to run in the private subnets of the VPC, routing outbound internet traffic through a NAT Gateway. In addition, the developer must enable active tracing on the Lambda function and use the AWS X-Ray SDK within the code to instrument the database client.
To satisfy both database access in a private subnet and public internet connectivity for external APIs, the Lambda function must be configured inside the private subnets of the VPC, with the private subnets routing outbound traffic to a NAT Gateway in a public subnet. Additionally, active tracing must be enabled on the Lambda function, and the database client within the codebase must be instrumented using the AWS X-Ray SDK to record downstream database queries.

Adım Adım Çözüm

1
Configure the Lambda function VPC settings.
The Lambda function is associated with the private subnets of the VPC where the RDS database is located.
This allows the Lambda function to gain network connectivity to the private database via local VPC routing.
2
Configure outbound routing for the private subnets.
A NAT Gateway is deployed in a public subnet, and the route table for the private subnets is configured to route 0.0.0.0/0 traffic to the NAT Gateway.
Since Lambda ENIs in a VPC do not have public IP addresses, they must route through a NAT Gateway in a public subnet to make outbound calls to the public internet.
3
Configure and instrument AWS X-Ray tracing.
Active tracing is enabled on the Lambda function, and the database client in the function code is wrapped or patched with the AWS X-Ray SDK.
Enabling active tracing captures Lambda execution segments, while SDK client patching propagates the tracing context to capture downstream database queries.

Anahtar Kavram

AWS Lambda VPC networking and downstream AWS X-Ray SDK database instrumentation.
Bu soruyu puanla