DVA-C02 Question 61
Select 2You are developing an AWS Lambda function that needs to access a private Amazon RDS database within a VPC in your account. How can you ensure the Lambda function can successfully connect to the database?
- A
Assign the Lambda function to the same VPC and subnet as the RDS database.
- B
Configure the Lambda function with appropriate security group rules that allow inbound traffic from the RDS database's security group.
- C
Attach an Elastic Network Interface (ENI) to the Lambda function to enable network connectivity.
- D
Ensure the RDS database's security group allows inbound traffic from the Lambda function's security group on the required port.
- E
Add a VPC endpoint to the Lambda function for the RDS database.
Show answer and explanation
Correct answers: A, D
Explanation
To access private resources in a VPC, such as an RDS database, a Lambda function must be assigned to the same VPC and subnet. Additionally, the RDS database's security group must allow inbound traffic from the Lambda function's security group on the necessary port for database communication. These configurations ensure proper network connectivity and security.
- A. Correct.
Correct: Lambda functions that need to access resources in a private VPC must be explicitly assigned to the same VPC and subnet to establish network connectivity.
- B. Incorrect.
Incorrect: Lambda functions do not require inbound traffic rules. Instead, the RDS database's security group must allow inbound traffic from the Lambda's security group.
- C. Incorrect.
Incorrect: ENIs are automatically managed by AWS when you configure a Lambda function to use a VPC. You do not manually attach ENIs to Lambda functions.
- D. Correct.
Correct: The RDS database's security group must allow inbound traffic from the security group of the Lambda function on the required port (e.g., 3306 for MySQL).
- E. Incorrect.
Incorrect: VPC endpoints are used for private connectivity to AWS services (e.g., S3, DynamoDB) and are not applicable for direct communication between Lambda and RDS.