Interview Prep/DevSecOps/Cloud IAM and Compliance

You find an IAM policy with `"Action": "*", "Resource": "*"` attached to an application role. How do you right-size it?

BeginnerScenarioCloud IAM and Compliance
Answer

Situation read → The app almost certainly uses a handful of APIs. Find out which ones from real usage, then shrink the policy.

What I'd do →

  1. Check last-accessed data: aws iam generate-service-last-accessed-details --arn <role-arn> then get-service-last-accessed-details.
  2. Use IAM Access Analyzer policy generation from CloudTrail for the role (90 days of activity).
  3. Write the new policy with specific actions and resource ARNs, e.g. s3:GetObject on arn:aws:s3:::orders-bucket/*.
  4. Deploy to staging, watch for AccessDenied in CloudTrail, adjust, then roll to prod.
  5. Add a Checkov or cfn-lint rule to block *:* in future IaC.

Why → Usage data removes the guesswork that keeps teams from tightening policies.

Interview tip → Mention Access Analyzer policy generation by name.

All DevSecOps questions Roadmap: Policy as code

More on Cloud IAM and Compliance