SAP-C02 Design for New Solutions Practice Question
A company is building a serverless application using AWS Lambda. The function needs to access a private Amazon RDS MySQL database. The Lambda function and the RDS instance are in the same VPC. What is the correct way to configure the Lambda function to connect to the database?
⚠ Common exam trap
Many exam-takers assume IAM roles or NAT Gateways provide network access, but AWS Lambda requires explicit VPC configuration with subnets and security groups to route traffic to private resources like RDS within the same VPC.
Answer choices
Why each option matters
Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.
Correct answer & explanation
✓
Configure the Lambda function to run in the same VPC, subnets, and security group as the RDS instance.
Lambda functions in a VPC must be configured with the same VPC, subnets, and security group as the RDS instance to establish direct network connectivity. By placing the Lambda function in the same security group, you can allow inbound traffic from the security group itself (self-referencing rule) or explicitly open the database port (e.g., 3306 for MySQL) to the Lambda's security group. This ensures traffic stays within the VPC and does not traverse the internet, meeting security and latency requirements.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✓
Configure the Lambda function to run in the same VPC, subnets, and security group as the RDS instance.
Why this is correct
This allows Lambda to connect to RDS over the network. The security group must allow inbound from Lambda's security group.
- ✗
Use a NAT Gateway to allow Lambda to access RDS through the internet.
Why it's wrong here
NAT Gateway is for outbound internet, not for inbound to RDS; also adds latency and cost.
- ✗
Assign an IAM role that allows Lambda to access RDS and configure the security group to allow traffic from the Lambda service.
Why it's wrong here
IAM controls permissions but does not provide network access; Lambda must be in the VPC.
- ✗
Attach an Elastic Network Interface (ENI) to the Lambda function in the same subnet as the RDS instance.
Why it's wrong here
Lambda automatically manages ENIs via VPC configuration; you cannot attach ENIs directly.
Visual reference
Quick reference
Cloud Service Model Comparison
| Model | You Manage | Provider Manages | Examples |
|---|---|---|---|
| IaaS | OS, runtime, apps, data | Hardware, hypervisor, networking | EC2, Azure VMs, GCP Compute Engine |
| PaaS | Apps and data | OS, runtime, middleware, hardware | Elastic Beanstalk, Azure App Service |
| SaaS | Data and settings only | Everything else | Microsoft 365, Salesforce, Workday |
| FaaS / Serverless | Function code only | Infra, scaling, runtime | Lambda, Azure Functions, Cloud Run |
| CaaS | Containers and apps | Kubernetes, OS, hardware | EKS, AKS, GKE |
Go deeper
Related to this question
About these practice questions
This SAP-C02 question is part of Courseiva's 1,660-question bank — original exam-style content with full explanations and wrong-answer analysis, never real exam questions or exam dumps. Learn why practice questions differ from exam dumps →
JA
Written by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
This SAP-C02 practice question is part of Courseiva's free Amazon Web Services certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the SAP-C02 exam.