Soru

Zorluk: KolayServerless Development with AWS Lambda

A company wants to connect a serverless microservice to an Amazon ElastiCache cluster located in a private VPC subnet. The microservice is implemented as an AWS Lambda function that must also call a public third-party weather API over the internet.

Which two configurations are required to establish this network connectivity? (Select two.)

  1. Associate the Lambda function with the private subnets of the VPC where the Amazon ElastiCache cluster is located.Cevap
  2. Configure a NAT Gateway in a public subnet, and update the private subnets' route tables to route outbound internet traffic to the NAT Gateway.Cevap
  3. C
    Deploy the Lambda function in a public subnet of the VPC and configure it with a public IPv4 address.
  4. D
    Assign the execution role a trust policy that permits direct internet routing without a NAT Gateway.
  5. E
    Embed static AWS credentials directly into the Lambda function's environment variables to authenticate with VPC endpoints.

Cevap

Associate the Lambda function with the private subnets of the VPC where the Amazon ElastiCache cluster is located, and configure a NAT Gateway in a public subnet to route outbound internet traffic from those private subnets.
To access private VPC resources such as an Amazon ElastiCache cluster, the Lambda function must be configured to run inside the VPC's private subnets. However, doing so removes its default internet access. To restore internet access (necessary for calling the external weather API), a NAT Gateway must be deployed in a public subnet, and the private subnets' route tables must direct 0.0.0.0/0 traffic through that NAT Gateway.

Adım Adım Çözüm

1
Configure the Lambda function's VPC settings with private subnets.
The Lambda function is allocated Elastic Network Interfaces (ENIs) inside the private subnets, enabling it to communicate with local resources like ElastiCache.
VPC-enabled Lambda functions must be assigned to subnets where target resources are accessible.
2
Set up a NAT Gateway in a public subnet and update route tables.
Outbound traffic originating from the private subnets is directed to the NAT Gateway, which routes it through the Internet Gateway to the public weather API.
Lambda functions in private subnets require a NAT Gateway (or NAT instance) to access public internet endpoints, as they do not receive public IP addresses.

Anahtar Kavram

AWS Lambda VPC networking and outbound internet connectivity
Bu soruyu puanla