Courseiva

DVA-C02 IAM Role Policy Practice Question

A developer is troubleshooting an AWS Lambda function that is failing with an 'AccessDenied' error when trying to write to an S3 bucket. The function's execution role has the following policy. What is the most likely cause of the failure? (Policy: { 'Version': '2012-10-17', 'Statement': [ { 'Effect': 'Allow', 'Action': 's3:PutObject', 'Resource': 'arn:aws:s3:::my-bucket/*' } ] })

⚠ Common exam trap

Candidates often focus solely on the identity-based policy and forget that a bucket policy can override it. Even with a correctly scoped role policy, a bucket policy denying access will cause AccessDenied.

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

✓

The S3 bucket has a bucket policy that denies the Lambda role access.

The IAM policy attached to the Lambda execution role correctly allows s3:PutObject on the bucket's objects. However, when a bucket policy explicitly denies access to the role or does not grant the required permissions, it takes precedence over the identity-based policy, resulting in an 'AccessDenied' error. Therefore, the most likely cause is a restrictive bucket policy.

Answer analysis

Option-by-option breakdown

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

  • ✗

    The resource ARN does not include the bucket itself; it only includes objects

    Why it's wrong here

    The resource ARN `arn:aws:s3:::my-bucket/*` is correctly formatted and scoped for actions like `s3:PutObject`. The `/*` wildcard specifically indicates that the permission applies to all objects *within* `my-bucket`, which is precisely where `s3:PutObject` operates. Including the bucket name without the `/*` would typically grant permissions on the bucket itself (e.g., `s3:ListBucket`), not its contents. Therefore, the ARN is not the cause of the failure.

  • ✓

    The S3 bucket has a bucket policy that denies the Lambda role access.

    Why this is correct

    AWS policy evaluation logic dictates that an explicit `Deny` statement in any policy always overrides an `Allow` statement, even if the `Allow` is present in an identity-based policy attached to the Lambda execution role. If the S3 bucket's resource policy explicitly denies the Lambda role access for `s3:PutObject`, this denial will take precedence, preventing the Lambda function from uploading objects despite its own role permissions. This is a common security control for resource owners.

  • ✗

    The action 's3:PutObject' is not allowed for Lambda execution roles

    Why it's wrong here

    Lambda execution roles are standard AWS IAM roles and can be granted permissions to perform any valid AWS service action, including `s3:PutObject`. There are no inherent restrictions preventing a Lambda function from interacting with S3 buckets to put objects, provided its associated execution role has the necessary `Allow` permissions. The ability to perform S3 operations is a fundamental capability for many serverless applications.

  • ✗

    The action 's3:PutObject' is not sufficient; need 's3:*'

    Why it's wrong here

    The `s3:PutObject` action is the specific and correct permission required for a Lambda function to upload an object to an S3 bucket. Broadening the permission to `s3:*` would grant excessive and unnecessary access, violating the principle of least privilege. If the Lambda function only needs to put objects, `s3:PutObject` is entirely sufficient and more secure than a wildcard action. The issue is not a lack of specific action, but rather an overriding denial.

Quick reference

AWS S3 Storage Class Comparison

Storage ClassMin DurationRetrievalUse Case
S3 StandardNoneImmediateFrequently accessed data
S3 Standard-IA30 daysImmediateInfrequent access, rapid retrieval
S3 One Zone-IA30 daysImmediateNon-critical infrequent data
S3 Intelligent-TieringNoneImmediate–hoursUnknown or changing access patterns
S3 Glacier Instant90 daysMillisecondsArchive with instant retrieval
S3 Glacier Flexible90 daysMinutes–hoursArchive, flexible retrieval
S3 Glacier Deep Archive180 daysHoursLong-term compliance archive

About these practice questions

One of 1,135 original DVA-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 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.