SAP-C02 Continuous Improvement for Existing Solutions Practice Question
A company runs a containerized application on Amazon ECS with Fargate. The application needs to securely access an Amazon S3 bucket. The company wants to follow the principle of least privilege. What should a solutions architect recommend?
⚠ Common exam trap
It's easy for candidates to confuse the ECS service-linked role (used for ECS service management) with the IAM task role (used for granting permissions to the containerized application), or incorrectly assume that Fargate tasks require an underlying EC2 instance 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
✓
Define an IAM task role with S3 access policies and reference it in the ECS task definition.
An IAM task role is the recommended mechanism for granting least-privilege permissions to ECS tasks using the Fargate launch type. The task role is defined in the ECS task definition and assumed by the container runtime, allowing the application to securely access the S3 bucket without embedding credentials. This approach follows AWS best practices by scoping permissions to the specific task rather than the underlying infrastructure.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✓
Define an IAM task role with S3 access policies and reference it in the ECS task definition.
Why this is correct
An IAM task role is assumed by the Fargate task itself, so containers receive temporary credentials scoped to the attached S3 policy. This avoids embedding long-lived keys and satisfies least privilege, since permissions are limited to the specific task rather than the host.
- ✗
Attach an IAM role to the underlying EC2 instance.
Why it's wrong here
Fargate has no underlying EC2 instance to attach a role to, so this cannot work. It is tempting because instance profiles are the standard mechanism for granting EC2-hosted workloads S3 access, and would be correct for an ECS launch-type deployment running on EC2 capacity.
- ✗
Assign an IAM role to the ECS service using the ECS service-linked role.
Why it's wrong here
The ECS service-linked role lets ECS itself call AWS APIs on your behalf, such as registering tasks; it grants the application no S3 permissions. It is tempting because it is an IAM role associated with ECS, and would be correct for enabling ECS service features like load balancer registration.
- ✗
Store AWS credentials in the container environment variables.
Why it's wrong here
Long-lived access keys in environment variables are static credentials that violate least privilege and risk exposure via task definitions or logs. This is tempting because environment variables are a familiar way to inject configuration into containers, and would suit non-AWS external services that cannot assume an IAM role.
Quick reference
AWS S3 Storage Class Comparison
| Storage Class | Min Duration | Retrieval | Use Case |
|---|---|---|---|
| S3 Standard | None | Immediate | Frequently accessed data |
| S3 Standard-IA | 30 days | Immediate | Infrequent access, rapid retrieval |
| S3 One Zone-IA | 30 days | Immediate | Non-critical infrequent data |
| S3 Intelligent-Tiering | None | Immediate–hours | Unknown or changing access patterns |
| S3 Glacier Instant | 90 days | Milliseconds | Archive with instant retrieval |
| S3 Glacier Flexible | 90 days | Minutes–hours | Archive, flexible retrieval |
| S3 Glacier Deep Archive | 180 days | Hours | Long-term compliance archive |
Go deeper
Related to this question
About these practice questions
This SAP-C02 question is part of Courseiva's 984-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 →
JA
Written by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
This SAP-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 SAP-C02 exam.