Courseiva
SecurityeasyMultiple ChoiceObjective-mapped

DVA-C02 Security Practice Question

A developer is building a serverless application using AWS Lambda functions that need to read and write to an Amazon DynamoDB table. What is the best practice for granting the Lambda function access to DynamoDB?

⚠ Common exam trap

Many candidates confuse resource-based policies (used for Lambda function invocation permissions) with execution roles (used for granting the Lambda function access to other AWS services), leading them to incorrectly choose Option C.

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 trust policy that allows Lambda to assume it, and attach a permissions policy granting DynamoDB access.

AWS Lambda functions require an IAM role (execution role) with a trust policy that allows Lambda to assume it, and a permissions policy that grants the necessary DynamoDB actions (e.g., GetItem, PutItem). This is the standard and secure method for granting permissions to Lambda, as it avoids hardcoding credentials 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 trust policy that allows Lambda to assume it, and attach a permissions policy granting DynamoDB access.

    Why this is correct

    The standard and most secure method for a Lambda function to interact with other AWS services, such as DynamoDB, is by assuming an IAM execution role. This role requires a trust policy allowing `lambda.amazonaws.com` to assume it, and an attached permissions policy explicitly granting the necessary DynamoDB actions. This mechanism provides temporary, scoped credentials, adhering to the principle of least privilege and ensuring secure access.

  • Create an IAM user and store the access keys in the Lambda environment variables.

    Why it's wrong here

    Storing IAM user access keys directly in Lambda environment variables is a severe security anti-pattern. These long-term credentials, if compromised, grant persistent access to resources and violate the principle of least privilege. AWS Lambda functions should instead leverage IAM execution roles, which automatically provide temporary, rotated credentials, eliminating the need to manage static access keys and significantly reducing security risks.

  • Attach a resource-based policy to the Lambda function that grants DynamoDB access.

    Why it's wrong here

    Resource-based policies define permissions for *other* AWS services or accounts to access a specific resource, such as allowing S3 to invoke a Lambda function. However, Lambda functions do not use resource-based policies to define their *outbound* permissions for accessing other AWS services like DynamoDB. Instead, a Lambda function's ability to call external services is governed exclusively by its assigned IAM execution role.

  • Use the Lambda function's default VPC role to access DynamoDB via a VPC endpoint.

    Why it's wrong here

    Lambda functions do not possess a 'default VPC role'; an explicit IAM execution role must always be configured to grant permissions for any AWS service interaction. While a Lambda function can be configured to operate within a VPC and utilize VPC endpoints for private connectivity to DynamoDB, the authorization to perform actions on DynamoDB still originates from its assigned execution role, not a non-existent VPC-specific role.

Quick reference

Cloud Service Model Comparison

ModelYou ManageProvider ManagesExamples
IaaSOS, runtime, apps, dataHardware, hypervisor, networkingEC2, Azure VMs, GCP Compute Engine
PaaSApps and dataOS, runtime, middleware, hardwareElastic Beanstalk, Azure App Service
SaaSData and settings onlyEverything elseMicrosoft 365, Salesforce, Workday
FaaS / ServerlessFunction code onlyInfra, scaling, runtimeLambda, Azure Functions, Cloud Run
CaaSContainers and appsKubernetes, OS, hardwareEKS, AKS, GKE

About these practice questions

This DVA-C02 question is part of Courseiva's 724-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 →

How Courseiva writes practice questions · Editorial policy

JA

Written by Johnson Ajibi, MSc IT Security

Senior Network & Security Engineer · founder of Courseiva

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.