Question

Difficulty: MediumDebugging Lambda Execution and Configuration Issues

An IoT telemetry ingestion application uses an AWS Lambda function to process device log files uploaded to an Amazon S3 bucket. The function parses the logs and sends alerts to an external monitoring API on the public internet. To securely query an Amazon ElastiCache Redis cluster, the Lambda function is configured to run inside private subnets of a VPC. The developer notices that the function successfully queries Redis but fails to send alerts to the external monitoring API, resulting in connection timeouts. Furthermore, under peak load, some executions are terminated prematurely before completion.

Which two actions should the developer take to resolve these issues? (Select TWO.)

  1. Configure a NAT gateway in a public subnet of the VPC, and update the route table of the Lambda function's private subnets to route 0.0.0.0/0 to the NAT gateway.Answer
  2. Increase the function's execution timeout setting in the AWS Lambda configuration.Answer
  3. C
    Enable the public IP assignment setting in the VPC configuration of the Lambda function.
  4. D
    Attach an Internet Gateway directly to the private subnets and update their route tables to direct 0.0.0.0/0 traffic to it.
  5. E
    Move the Redis connection initialization inside the Lambda handler function to prevent the execution context from reusing stale connections that cause timeouts.

Answer

The developer should configure a NAT gateway in a public subnet with a route in the private subnets' route table, and increase the execution timeout in the Lambda function's configuration.
To resolve the network connectivity issue, a NAT gateway must be set up in a public subnet, and the route table for the private subnets (where the Lambda function runs) must route outbound traffic (0.0.0.0/0) to the NAT gateway. To resolve the premature termination issue under peak load, the Lambda function's timeout configuration must be increased to allow enough time for processing larger logs.

Step-by-Step Solution

1
Diagnose the connection timeouts to the external API.
Identify that the Lambda function is in private subnets and lacks internet access because it does not have a route to a NAT gateway.
Lambda functions in a VPC require a NAT gateway or NAT instance to route traffic to the public internet.
2
Configure outbound internet access for the VPC private subnets.
Provision a NAT gateway in a public subnet and update the private subnets' route tables to send all 0.0.0.0/0 traffic to the NAT gateway.
This allows the Lambda function in the private subnets to send requests to the external monitoring API while retaining internal access to the ElastiCache cluster.
3
Diagnose the premature termination of Lambda executions under peak load.
Recognize that the execution time is exceeding the configured Lambda timeout limit.
Heavier payloads or peak traffic require longer processing times, so the Lambda execution timeout configuration must be increased.

Key Concept

Configuring VPC networking for Lambda internet access and managing Lambda execution timeouts
Rate this question