Development with AWS Services A free question from our original DVA-C03 practice exam. Try it, then open the answer to see why each option is right or wrong.
A Lambda function is attached to private subnets so that it can query an Amazon RDS database, which must stay private.
The function must also call a payment provider's HTTPS API. The provider accepts requests only from one fixed public IP address that the company has registered with it. Calls to the provider currently time out.
The company will not open the database to the internet.
Which change meets these requirements?
Choose one answer.
AA. Move the function into the VPC's public subnets, so that its traffic leaves through the internet gateway.
BB. Add a route from the private subnets to the internet gateway, and allow outbound traffic in the security group.
CC. Create a NAT gateway in a public subnet with an Elastic IP, and route the private subnets' traffic to it.
DD. Create an interface VPC endpoint for the payment provider's domain name in the private subnets, and turn on private DNS.
B. Wrong: The function has no public IP address, so the internet gateway cannot carry its traffic. The provider would still never see the fixed address it expects.
C. Right: Correct. Outbound traffic from the private subnets leaves through the NAT gateway, which uses its Elastic IP address. The provider sees that fixed address, and the database stays private. Learn more: NAT gateways (opens in a new tab)
D. Wrong: Interface endpoints reach AWS services and PrivateLink services. They cannot reach an arbitrary third-party API, and they do not give the function a fixed outbound address.
Explanation
A function in private subnets reaches the internet only through a route to a NAT gateway in a public subnet. The NAT gateway's Elastic IP address is the fixed address the provider sees, and the database stays private. Public subnets and internet gateway routes do not give the function a public address.
The provider sees the NAT gateway's Elastic IP, and the database never gets a route to the internet.
Want more on Lambda and VPC access? The 5 full-length practice sets have 5 more Lambda and VPC access questions, 390 in all, none of them in the free exam. One payment of $14.99, no subscription. See the practice sets →