Principle of Least Privilege IAM
Explain least privilege for cloud IAM. Give an example of a bad vs good policy for an app reading one S3 prefix.
Answers use simple, clear English.
Audio N/AQuick interview answer
Grant only the permissions required for the job, on the smallest resource scope, for the shortest time. Bad: s3:* on *. Good: s3:GetObject on arn:aws:s3:::bucket/app/* bound to a role assumed by that workload.
Detailed answer
Grant only the permissions required for the job, on the smallest resource scope, for the shortest time. Bad: s3:* on *. Good: s3:GetObject on arn:aws:s3:::bucket/app/* bound to a role assumed by that workload. Prefer roles over long-lived access keys. Privilege creep happens when policies are copied and never reviewed.
Full explanation
Privilege creep happens when policies are copied and never reviewed.
Real example & use case
CI job role can push only to the ECR repo for that service, not delete clusters.
Pros & cons
Pros: limits blast radius of leaks. Cons: tighter policies need better packaging/tooling for developers.