An AWS managed policy grants a pipeline role read access to every S3 bucket, but the role needs only two prefixes in one bucket. What should the engineer do?
- Exam domain
- Data Security and Governance18% of the exam
- Difficulty
- Medium
- In this mock
- 19 questions on this domainPractise this domain
Why the exam asks this
Task Statement 4.2: Apply authorization mechanisms.
Objective in the exam guide: Create custom IAM policies when a managed policy does not meet the needs; construct custom policies that meet the principle of least privilege.
Broad managed policies are convenient and dangerous. Writing narrow custom policies is a core security skill for data engineers.
Why C is the answer
Write a custom IAM policy that allows only the needed actions on those two prefixes
When a managed policy grants too much, a custom least-privilege policy limits access to what is needed.
Remember: When a managed policy is too broad, write a custom least-privilege policy.
How it works
AWS managed policies are convenient but often grant more than one workload needs.
A custom policy can name exactly the actions and resources required, such as reads on two prefixes.
Least privilege limits the damage if the role is ever misused.
Clues in the question
The words that point to the answer, and what each one tells you.
- Every S3 bucket, but needs two prefixes
- The managed policy is too broad.
In detail
- Least privilege means the minimum actions on the minimum resources.
- IAM Access Analyzer can help generate and review policies.
Side by side with look-alikes
| Policy | Least privilege? |
|---|---|
| Custom, two prefixes | Yes |
| Managed, all buckets | No |
| AdministratorAccess | No |
Every option, checked
Knowing why each wrong option fails is how you rule it out on exam day.
A. Attach AdministratorAccess to be safeWrong
Administrator access is the opposite of least privilege.
B. Share the role with other teamsWrong
Sharing roles spreads access further.
C. Write a custom IAM policy that allows only the needed actions on those two prefixesRight
When a managed policy is too broad, write a custom least-privilege policy.
D. Keep the managed policy, since it is maintained by AWSWrongMost tempting
Being maintained by AWS does not make it narrow enough.
Why it tempts: AWS maintains it, which sounds safe. But maintenance does not make it narrow; it still grants far too much.
In practice
- Use IAM Access Analyzer to check for unused permissions.
Use case
An illustrative scenario, not a real incident.
A custom policy allowing s3:GetObject on two prefixes replaces read access to every bucket.
See how it works
flowchart LR R["Pipeline role"] --> A["Allowed: s3://data/orders/*"] R --> B["Allowed: s3://data/refunds/*"] R -.->|"Denied"| C["Every other bucket and prefix"]
How to read this chart
- At "Pipeline role": otherwise, go to "Allowed: s3://data/orders/*"; otherwise, go to "Allowed: s3://data/refunds/*"; if "Denied", go to "Every other bucket and prefix".