Question

Difficulty: MediumDebugging Lambda Execution and Configuration Issues

A developer has built a serverless application where an AWS Lambda function, written in Python, processes payment reports. The Lambda function is configured to run inside a VPC, attached to two private subnets, to securely access a private Amazon RDS PostgreSQL database.

As part of the processing logic, the Lambda function must perform the following actions:
1. Connect to the RDS database to fetch payment transactions.
2. Query a public external credit rating API via HTTPS to validate client records.
3. Download a standard currency conversion schema from a public Amazon S3 bucket.

During testing, the Lambda function consistently runs for its maximum configured timeout of 33 seconds and then terminates with a `Task timed out after 3.00 seconds` error. The Amazon CloudWatch logs indicate that the connection to the RDS database is established successfully, but the connections to both the external credit rating API and Amazon S3 fail to connect.

Which combination of actions should the developer take to resolve these connectivity and execution timeout issues? (Select TWO.)

  1. Deploy a NAT Gateway in a public subnet of the VPC, and update the private subnets' route tables to direct internet-bound traffic (0.0.0.0/00.0.0.0/0) to the NAT Gateway.Answer
  2. Increase the Lambda function's timeout configuration to a value greater than 33 seconds (such as 1515 seconds) to accommodate network transit and API latency.Answer
  3. C
    Relocate the Lambda function to the public subnets of the VPC and enable the auto-assign public IP option on those subnets to establish direct internet access.
  4. D
    Create an Internet Gateway and associate it directly with the private subnets' route tables to provide an outbound pathway for the Lambda function.
  5. E
    Configure the Lambda function to tear down and recreate the database connection pool at the end of each handler execution to clear the cached execution context.

Answer

Deploy a NAT Gateway in a public subnet of the VPC and update the private subnets' route tables to route internet traffic to it, and increase the Lambda function's timeout configuration to a value greater than 33 seconds.
The correct answers describe deploying a NAT Gateway in a public subnet to allow the private-subnet Lambda function to reach the public internet (for S3 and the external API), and increasing the function's timeout configuration to accommodate the network transit time and database operations. These two adjustments work together to resolve both the networking bottleneck and the execution duration limitation.

Step-by-Step Solution

1
Diagnose the routing issue by reviewing subnets and endpoints.
The Lambda function is running in private VPC subnets with no route to the internet, causing external HTTP/HTTPS calls to time out.
VPC-enabled Lambda functions require a NAT Gateway (or VPC Endpoints) to reach endpoints outside the VPC.
2
Establish outbound connectivity for public endpoints.
Deploy a NAT Gateway in a public subnet and route traffic destined for 0.0.0.0/00.0.0.0/0 from the private subnets to the NAT Gateway.
This configuration allows the Lambda function to securely reach both the external API and the public S3 bucket.
3
Adjust the execution configuration of the Lambda function.
Increase the timeout configuration from 33 seconds to a higher limit (e.g., 1515 seconds).
The execution environment needs sufficient time to establish connections, query the database, and receive external API responses without timing out prematurely.

Key Concept

VPC networking configurations and execution environment settings for AWS Lambda functions
Rate this question