Soru

Zorluk: KolayDebugging Lambda Execution and Configuration Issues

A developer has configured an AWS Lambda function inside a private subnet of a VPC to connect to an internal database. The function also needs to call an external API on the public internet, but all connection attempts to the external API time out. Which configuration change will resolve this issue while maintaining access to the private database?

  1. Route the outbound traffic from the private subnet containing the Lambda function through a NAT Gateway.Cevap
  2. B
    Move the Lambda function to a public subnet within the VPC to allow direct internet access.
  3. C
    Configure the Lambda function to assign a public IP address to its Elastic Network Interface (ENI).
  4. D
    Increase the Lambda function's execution timeout limit to allow the connection to succeed.

Cevap

Route the outbound traffic from the private subnet containing the Lambda function through a NAT Gateway.
For a Lambda function inside a VPC to access the internet, it must be placed in a private subnet. The outbound traffic from this private subnet must be routed to a NAT Gateway located in a public subnet, which then routes the traffic to the internet through an Internet Gateway.

Adım Adım Çözüm

1
Identify the networking requirements of the Lambda function.
The Lambda function needs to communicate with an internal database inside the VPC and an external API on the public internet.
Placing a Lambda function inside a VPC restricts its default direct internet access.
2
Determine the proper routing configuration for internet access from a VPC.
Lambda functions in a VPC require a NAT Gateway (or NAT instance) to translate private subnet traffic to the public internet.
Lambda functions do not get public IP addresses assigned to their network interfaces, meaning they cannot use an Internet Gateway directly.
3
Configure the subnet route tables.
Add a route to the private subnet's route table pointing 0.0.0.0/0 traffic to the NAT Gateway in the public subnet.
This establishes a valid outbound path to the internet for resources inside the private subnet.

Anahtar Kavram

VPC Lambda Internet Connectivity
Bu soruyu puanla