Courseiva

SCS-C02 Identity and Access Management Practice Question

An AWS Lambda function needs to read from a DynamoDB table. What is the best practice for granting the Lambda function the necessary permissions?

⚠ Common exam trap

SCS-C02 often tests the misconception that Lambda can use IAM user credentials or resource-based policies for same-account access, when the correct and secure practice is an IAM execution role.

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 the necessary permissions and attach it as the Lambda function's execution role.

The best practice for granting a Lambda function permissions to DynamoDB is to create an IAM role with the necessary permissions and attach it as the function's execution role. Lambda assumes this role at runtime, and the AWS SDK automatically uses temporary credentials from the role, eliminating the need to manage long-term keys. This follows the principle of least privilege and avoids embedding secrets.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • ✗

    Use a resource-based policy on the DynamoDB table to allow the Lambda function.

    Why it's wrong here

    DynamoDB does not support resource-based policies. Unlike Amazon S3 or SNS, DynamoDB tables can only be controlled through IAM identity-based policies attached to users, roles, or groups. A Lambda function cannot be granted access to a DynamoDB table via a table-attached policy; instead, the function's execution role must contain the required DynamoDB permissions.

  • ✗

    Create an IAM user with the necessary permissions and assign it to the Lambda function.

    Why it's wrong here

    Lambda functions do not have login credentials and cannot be assigned an IAM user. IAM users are long-term identities intended for human users or applications that require static credentials. To grant a Lambda function access to DynamoDB, you must create an IAM role and set it as the function's execution role, which allows the service to assume that role with temporary credentials.

  • ✓

    Create an IAM role with the necessary permissions and attach it as the Lambda function's execution role.

    Why this is correct

    Attaching an IAM role as the Lambda function's execution role is the recommended pattern. In the role's trust policy you allow the Lambda service principal, lambda.amazonaws.com, to assume the role; the role's permissions policy then grants the minimal DynamoDB actions needed, such as GetItem or Query. Lambda automatically calls sts:AssumeRole and obtains short-term credentials, so no long-lived keys are ever stored in the function.

  • ✗

    Embed the IAM user's access key and secret key in the Lambda function code.

    Why it's wrong here

    Embedding an IAM user's access key and secret key in Lambda code is insecure and violates AWS best practices. Long-term user credentials can be easily exposed in source control, logs, or error messages, and there is no automatic rotation. Lambda execution roles provide temporary credentials that are automatically rotated and are the recommended method for accessing DynamoDB.

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

One of 1,205 original SCS-C02 practice questions on Courseiva, each with a full explanation and wrong-answer analysis — not exam dumps or protected exam content. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

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 SCS-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 SCS-C02 exam.