DVA-C02 Security Practice Question
A company has a DynamoDB table that stores personally identifiable information (PII). A developer needs to allow a Lambda function to read and write to this table. What is the MOST secure way to grant the Lambda function access?
⚠ Common exam trap
DVA-C02 often tests whether candidates know that Lambda automatically assumes an execution role — the trap is picking STS AssumeRole inside the function or embedding credentials, which are either redundant or insecure.
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
✓
Create an IAM role with a policy that allows DynamoDB read/write access and attach it to the Lambda function.
Attaching an IAM role with a least-privilege policy to the Lambda function is the AWS-recommended, most secure approach. Lambda assumes the execution role automatically at invocation, and no long-lived credentials are stored anywhere. This eliminates credential leakage risk and follows the principle of least privilege.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✓
Create an IAM role with a policy that allows DynamoDB read/write access and attach it to the Lambda function.
Why this is correct
An IAM role attached to the Lambda function supplies temporary credentials via the execution environment, so no long-term keys are stored. Scoping the policy to the specific DynamoDB table actions follows least privilege, satisfying the PII security requirement.
- ✗
Use a resource-based policy on the DynamoDB table to allow the Lambda function's IAM role.
Why it's wrong here
DynamoDB does not support resource-based policies granting Lambda access; permissions must come through the function's IAM execution role. It is tempting because resource-based policies are the standard mechanism for cross-account access to S3 and SQS, but DynamoDB relies on identity-based IAM policies instead.
- ✗
Create an IAM user with programmatic access and embed the credentials in the Lambda environment variables.
Why it's wrong here
Embedding IAM user credentials in Lambda environment variables violates the principle of least privilege because static long-term access keys cannot be automatically rotated and remain exposed in plaintext, whereas the correct approach uses an IAM role with a trust policy that grants the Lambda function temporary credentials via the AWS Security Token Service. This option is tempting because IAM users with programmatic access are the standard method for granting API access to external applications, and environment variables are a convenient way to inject configuration; in a scenario where a non-AWS service or an on-premises application must authenticate to DynamoDB, an IAM user with embedded credentials would be the correct choice.
- ✗
Have the Lambda function assume a role using AWS STS each time it runs.
Why it's wrong here
Lambda already receives temporary credentials from its execution role, so calling STS AssumeRole adds no security and introduces latency and extra trust-policy complexity. STS AssumeRole suits cross-account access or federation from outside AWS, not a function's own permissions.
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 DVA-C02 question is part of Courseiva's 1,135-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 and reviewed by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
Last reviewed September 2026 · checked against the official Amazon Web Services exam blueprint
This DVA-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 DVA-C02 exam.