DVA-C02 Question 63
Select 2You are developing a serverless application using AWS Lambda. Your Lambda function needs to access a private RDS database hosted in a VPC. How can you ensure the Lambda function has the necessary network connectivity to access the RDS instance?
- A
Associate the Lambda function with a VPC and configure appropriate subnets and security groups.
- B
Add an Internet Gateway to the VPC to allow the Lambda function to access private resources.
- C
Ensure that the Lambda function's execution role has permissions to access the RDS instance.
- D
Configure the Lambda function to run in public subnets to access the private RDS instance.
- E
Add a NAT Gateway to the VPC if the Lambda function needs outbound internet access for other tasks.
Show answer and explanation
Correct answers: A, E
Explanation
To access private resources like an RDS instance in a VPC, a Lambda function must be configured to run within the VPC by associating it with appropriate subnets and security groups. Additionally, if the Lambda function needs internet access for other outbound tasks, a NAT Gateway must be configured. Other options like using an Internet Gateway or placing the Lambda function in public subnets are not applicable for accessing private resources within the VPC.
- A. Correct.
Correct: To access private resources in a VPC, the Lambda function must be associated with the VPC and use the appropriate subnets and security groups.
- B. Incorrect.
Incorrect: An Internet Gateway is used to allow internet access to resources in a VPC, not for accessing private resources within the VPC.
- C. Incorrect.
Incorrect: While the Lambda execution role may need permissions for accessing the RDS instance, this pertains to IAM and does not affect network connectivity.
- D. Incorrect.
Incorrect: Running the Lambda function in public subnets does not grant access to private resources in the VPC. For private resources, subnets in the VPC must be configured correctly.
- E. Correct.
Correct: If the Lambda function requires outbound internet access (e.g., for accessing other AWS services or external APIs), a NAT Gateway must be configured in the VPC.