Courseiva
Development with AWS ServicesmediumMultiple ChoiceObjective-mapped

DVA-C02 Development with AWS Services Practice Question

A company runs a containerized web application on Amazon ECS using Fargate. The application needs to store files in Amazon S3. The developer wants to follow the principle of least privilege for the ECS task IAM role. Which IAM policy should be attached to the task role?

⚠ Common exam trap

It's easy for candidates to choose Option D thinking both read and write are needed for storing files, but the question explicitly states 'store files' which implies write-only, making the read permission unnecessary and a violation of least privilege.

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

{"Version":"2012-10-17","Statement":[{"Effect":"Allow","Action":"s3:PutObject","Resource":"arn:aws:s3:::example-bucket/*"}]}

It grants only the s3:PutObject action on the specific S3 bucket, which is the minimum permission required for the application to store files. This adheres to the principle of least privilege by not including unnecessary read or list actions. The task role should be scoped to the exact resource and action needed.

Answer analysis

Option-by-option breakdown

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

  • {"Version":"2012-10-17","Statement":[{"Effect":"Allow","Action":"s3:*","Resource":"*"}]}

    Why it's wrong here

    This policy grants full administrative access to *all* Amazon S3 buckets and objects across the entire AWS account due to the `s3:*` action and `*` resource. Such broad permissions violate the principle of least privilege by allowing actions far beyond merely uploading files, including deleting buckets, modifying permissions, or accessing sensitive data in any S3 resource. This poses a severe security vulnerability if the container's credentials are ever compromised, allowing an attacker to control all S3 data.

  • {"Version":"2012-10-17","Statement":[{"Effect":"Allow","Action":"s3:*","Resource":"arn:aws:s3:::example-bucket/*"}]}

    Why it's wrong here

    While this policy correctly restricts the resource to objects within `arn:aws:s3:::example-bucket/*`, the `s3:*` action still grants permissions for *all* S3 object-level operations on that bucket. This includes unnecessary actions like `s3:DeleteObject`, `s3:RestoreObject`, and `s3:GetObjectAcl`, which are not required solely for uploading files. Granting such extensive permissions, even to a specific bucket, violates the principle of least privilege and introduces an elevated risk of unintended or malicious data manipulation.

  • {"Version":"2012-10-17","Statement":[{"Effect":"Allow","Action":"s3:PutObject","Resource":"arn:aws:s3:::example-bucket/*"}]}

    Why this is correct

    This policy precisely adheres to the principle of least privilege, granting only the `s3:PutObject` action, which is the exact permission required for the web application to upload files to Amazon S3. The resource is correctly scoped to `arn:aws:s3:::example-bucket/*`, ensuring the application can only write objects into the specified bucket and not affect other S3 resources or perform any other S3 operations. This minimal permission set significantly enhances security by limiting potential damage if the task's credentials were ever compromised.

  • {"Version":"2012-10-17","Statement":[{"Effect":"Allow","Action":["s3:GetObject","s3:PutObject"],"Resource":"arn:aws:s3:::example-bucket/*"}]}

    Why it's wrong here

    This policy is overly permissive because it includes `s3:GetObject` in addition to the necessary `s3:PutObject` action. While `s3:PutObject` is essential for uploading, `s3:GetObject` grants read access to objects within `example-bucket`, which is not explicitly required for the task of *uploading* files. Granting unnecessary read permissions violates the principle of least privilege, potentially exposing data or allowing unauthorized retrieval if the application only needs to write, thereby increasing the attack surface.

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

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.