Courseiva
Question 431 of 724
SecurityeasyMultiple ChoiceObjective-mapped

DVA-C02 Security Practice Question

A developer needs to grant a Lambda function permission to write logs to CloudWatch Logs. Which IAM entity should be used?

⚠ Common exam trap

Many exam-takers confuse the entity that receives permissions (the Lambda function) with the mechanism that grants them (an execution role), leading candidates to incorrectly select attaching a policy directly to the function or using a resource-based policy.

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 execution role with the necessary permissions and associate it with the function.

Lambda functions require an IAM execution role to obtain temporary credentials for accessing other AWS services. This role must include a trust policy allowing Lambda to assume it and a permissions policy granting the specific actions (e.g., logs:CreateLogGroup, logs:CreateLogStream, logs:PutLogEvents) on CloudWatch Logs. Associating this role with the function is the standard and secure way to grant permissions.

Answer analysis

Option-by-option breakdown

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

  • Attach an inline policy to the Lambda function.

    Why it's wrong here

    Attaching an inline policy directly to a Lambda function is not a supported mechanism within AWS IAM. Lambda functions do not act as direct IAM principals that can have policies attached to their resource ARN in this manner. Instead, Lambda functions assume an IAM execution role, and any necessary permissions, whether defined by inline or managed policies, must be attached to that specific role.

  • Create an IAM execution role with the necessary permissions and associate it with the function.

    Why this is correct

    Creating an IAM execution role with the necessary permissions and associating it with the Lambda function is the correct and standard approach. This execution role defines the specific actions the Lambda function is authorized to perform when it executes, such as reading from S3, writing to DynamoDB, or publishing logs to CloudWatch. The Lambda service assumes this role on behalf of your function, ensuring adherence to the principle of least privilege.

  • Use a service control policy (SCP) to allow logging.

    Why it's wrong here

    Using a Service Control Policy (SCP) to allow logging is an incorrect approach because SCPs operate at the AWS Organizations level, not at the individual resource level. SCPs define maximum permissions for all IAM principals within an account or Organizational Unit (OU), acting as guardrails to restrict what can be done. They do not grant specific permissions to individual Lambda functions or any other resource; rather, they filter the effective permissions granted by IAM policies.

  • Add a resource-based policy to the Lambda function.

    Why it's wrong here

    Adding a resource-based policy to the Lambda function is not the correct method for granting the function permissions to interact with other AWS services. A resource-based policy on a Lambda function, often called a Lambda permission policy, specifies *who* (which AWS service or account) is allowed to *invoke* that particular Lambda function. It does not define the permissions the function itself possesses to perform actions like writing logs or accessing other resources during its execution.

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

Courseiva creates original exam-style practice questions with explanations and wrong-answer analysis. It does not publish real exam questions, exam dumps, or protected exam content. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

Last reviewed: Jun 24, 2026

Question Discussion

Share a tip, memory trick, or ask about the reasoning behind this question. Do not post real exam questions, leaked content, braindumps, or copyrighted exam material. Comments are moderated and may be removed without notice.

Loading comments…

Sign in to join the discussion.

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.