An order processing service runs on AWS Lambda. To comply with security guidelines, this function is attached to private subnets within a VPC to query an Amazon Aurora database. As part of its execution, the function must also call an external payment gateway API over the internet. Although the database queries succeed, all external API calls timeout. What configuration change is required to allow the function to connect to the external API?
- ARelocate the Lambda function configuration from the private subnets to the public subnets of the VPC to grant it a public IP address.
- Create a NAT gateway in a public subnet of the VPC and configure a route for outbound internet traffic in the private subnet's route table.Cevap
- CExtend the execution timeout of the Lambda function to allow more time for the external API requests to complete.
- DUpdate the Lambda function's IAM execution role trust policy to allow the VPC endpoints to assume the role.
Cevap
Create a NAT gateway in a public subnet of the VPC and configure a route for outbound internet traffic in the private subnet's route table.
The correct action is to create a NAT gateway in a public subnet and configure a route in the private subnet's route table. When a Lambda function is configured to run inside a VPC, it does not have direct internet access. To access an external API, outbound internet traffic must be routed through a NAT gateway located in a public subnet.
Adım Adım Çözüm
Anahtar Kavram
VPC Networking for AWS Lambda