Soru

Zorluk: OrtaServerless Development with AWS Lambda

An enterprise application requires a backend component to process payment transactions. A software engineer is designing an AWS Lambda function that must connect to a PostgreSQL database hosted inside a private VPC subnet, and also make HTTPS requests to an external payment processor's public API endpoint. Which configuration should the software engineer implement to meet these requirements?

  1. A
    Configure the Lambda function to run in the public subnets of the VPC, and route outbound internet traffic through an Internet Gateway.
  2. B
    Configure the Lambda function to run outside the VPC, and use an IAM trust policy to authorize secure access to the private database's IP address.
  3. Configure the Lambda function to run in the private subnets of the VPC, and route outbound internet traffic through a NAT Gateway placed in a public subnet.Cevap
  4. D
    Configure the Lambda function to run in the private subnets of the VPC, and use a VPC Gateway Endpoint to route traffic to the external payment processor's API.

Cevap

Configure the Lambda function to run in the private subnets of the VPC, and route outbound internet traffic through a NAT Gateway placed in a public subnet.
To access both a private VPC resource (the database) and a public API, the Lambda function must be associated with the private subnets of the VPC. Since Lambda functions inside a VPC are not assigned public IP addresses, they cannot communicate directly with the internet via an Internet Gateway. Instead, outbound internet traffic must be routed from the private subnets to a NAT Gateway situated in a public subnet of the VPC.

Adım Adım Çözüm

1
Determine the networking requirements of the Lambda function.
The Lambda function needs to access a private database (requires VPC access) and a public API (requires internet access).
Understanding the dual requirements (VPC and Internet access) is critical to selecting the correct network configuration.
2
Evaluate the placement of the Lambda function.
The Lambda function must be placed inside the private subnets of the VPC to securely connect to the database.
Placing resources in the same VPC allows network interface creation and secure internal routing.
3
Determine how to enable internet access for VPC-bound resources.
Configure a NAT Gateway in a public subnet of the VPC, and update the private subnet's route table to direct 0.0.0.0/0 traffic to the NAT Gateway.
Lambda functions in a VPC do not get public IPs and cannot use an Internet Gateway directly; they require a NAT Gateway for outbound internet access.

Anahtar Kavram

VPC Networking for AWS Lambda
Bu soruyu puanla