A developer is troubleshooting an AWS Lambda function that performs real-time currency conversion for a financial auditing application. The function is configured to run inside a VPC and is associated with two private subnets. It must read transaction data from an Amazon Aurora MySQL database cluster in the same VPC and fetch the latest exchange rates from a public API endpoint over the internet. While the database queries succeed, all HTTP requests to the public exchange rate API fail with connection timeout errors. Which of the following actions should the developer take to resolve this connectivity issue?
- Deploy a NAT Gateway in a public subnet of the VPC, and add a route in the private subnets' route table directing outbound internet traffic (0.0.0.0/0) to the NAT Gateway.Cevap
- BAssociate the Lambda function with public subnets of the VPC, enabling direct internet access through the VPC Internet Gateway.
- CCreate an Egress-Only Internet Gateway in the VPC and add a route in the private subnets' route table directing outbound IPv4 traffic to it.
- DIncrease the Lambda function's execution timeout limit to allow the execution context to persist stale database connections and avoid outbound socket timeouts.
Cevap
Deploy a NAT Gateway in a public subnet of the VPC, and add a route in the private subnets' route table directing outbound internet traffic (0.0.0.0/0) to the NAT Gateway.
The correct answer is to deploy a NAT Gateway in a public subnet and add a route in the private subnets' route table. Since Lambda functions inside a VPC only receive private IP addresses from the subnets they are associated with, they cannot communicate with the internet directly. By routing outbound traffic through a NAT Gateway in a public subnet, the Lambda function can securely access the public API.
Adım Adım Çözüm
Anahtar Kavram
VPC Networking for AWS Lambda Functions
Tahmini Süre:2m 0s