DVA-C02 Security Practice Question
A company uses an S3 bucket to store sensitive customer data. The bucket policy currently allows access to a specific IAM role used by an EC2 instance. A security audit reveals that the bucket is also accessible from an external AWS account. Which action should the security team take to restrict access to only the intended role?
⚠ Common exam trap
Test-takers frequently confuse IAM role trust policies with resource-based policies (like S3 bucket policies), thinking that modifying the trust policy will control access to the bucket, when in fact the bucket policy itself must explicitly restrict the principal.
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
✓
Add a condition in the bucket policy to allow access only when the request includes the specific IAM role ARN.
Adding a condition in the bucket policy using the `aws:PrincipalArn` condition key allows you to restrict access exclusively to the specific IAM role ARN. This ensures that even if the bucket policy grants access to an external AWS account, only requests made by the designated IAM role (e.g., `arn:aws:iam::123456789012:role/EC2AppRole`) will be allowed, effectively blocking any other principals, including those from external accounts.
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 S3 Object Ownership to disable ACLs.
Why it's wrong here
Using S3 Object Ownership to disable ACLs primarily dictates how object ownership is handled and whether ACLs are used for access control at all. While disabling ACLs can simplify permission management by centralizing control in bucket policies, it does not, by itself, provide the specific mechanism to restrict access to an S3 bucket based on a particular IAM role ARN. This feature focuses on ownership and ACL enforcement, not on principal-based access conditions.
- ✗
Enable S3 Block Public Access on the bucket.
Why it's wrong here
Enabling S3 Block Public Access is a crucial security measure designed to prevent public access to S3 buckets and objects, typically blocking anonymous access or access granted to 'everyone' via ACLs or bucket policies. However, this feature does not prevent legitimate, controlled cross-account access when explicitly granted to a specific AWS account or IAM principal through a bucket policy. It targets 'public' exposure, not authorized cross-account access to a specific IAM role.
- ✗
Modify the IAM role trust policy to only allow the EC2 instance.
Why it's wrong here
An IAM role's trust policy defines which principals (e.g., an EC2 instance, another AWS account, or an IAM user) are authorized to assume that specific role. While essential for identity federation, it governs *who can become* the role, not *what the role can access* once assumed. Modifying the trust policy to restrict who can assume the role does not directly control the bucket's access permissions for the assumed role; that control resides with the S3 bucket policy.
- ✓
Add a condition in the bucket policy to allow access only when the request includes the specific IAM role ARN.
Why this is correct
Adding a condition in the S3 bucket policy is the precise method for restricting access to a specific IAM role. By utilizing a condition key like `aws:PrincipalArn` or `aws:SourceArn` within the bucket policy's `Condition` block, you can ensure that S3 operations are permitted only when the requesting principal's ARN matches the specified IAM role. This directly enforces the principle of least privilege by granting access exclusively to the intended role, even across accounts.
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
One of 724 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 →
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.