Question

Difficulty: MediumServerless Development with AWS Lambda

A developer is configuring an AWS Lambda function that must query an Amazon Aurora PostgreSQL database cluster deployed in private subnets within a VPC. The Lambda function also needs to call an external, third-party payment processing API on the public internet. Which network configurations must the developer implement to enable this connectivity? (Select two.)

  1. Associate the Lambda function with the private subnets where the Amazon Aurora database cluster resides.Answer
  2. Configure a NAT Gateway in a public subnet, and update the route tables of the private subnets to route outbound traffic through the NAT Gateway.Answer
  3. C
    Associate the Lambda function with the public subnets of the VPC to allow direct outbound internet communication.
  4. D
    Update the IAM execution role of the Lambda function with a trust policy that allows the vpc.amazonaws.com service principal to assume the role.
  5. E
    Initialize the database client by hardcoding the DB credentials in the environment variables and using a custom SDK credential provider inside the handler.

Answer

Associate the Lambda function with the private subnets where the Amazon Aurora database cluster resides, and configure a NAT Gateway in a public subnet while updating the route tables of the private subnets to route outbound traffic through the NAT Gateway.
To connect the Lambda function to the database, it must be integrated with the VPC and associated with the private subnets where the database resides. To connect to the external payment API from inside the private subnets, a NAT Gateway must be configured in a public subnet, and the private subnet route tables must be updated to route outbound traffic to the NAT Gateway.

Step-by-Step Solution

1
Analyze the database connectivity requirement.
The Lambda function needs to query an Amazon Aurora database cluster in private subnets. To reach it, the Lambda function must be configured to associate with those private subnets.
This creates Elastic Network Interfaces (ENIs) inside the private subnets, enabling local network communication within the VPC.
2
Analyze the external API connectivity requirement.
The Lambda function in private subnets requires internet access to reach the third-party API. A NAT Gateway must be set up in a public subnet, and the private subnet route tables must direct 0.0.0.0/0 traffic to it.
This allows outbound-only internet traffic to flow from the private subnets to the public internet.

Key Concept

AWS Lambda VPC networking configuration for internal and external resources
Rate this question