Least privilege means granting only the permissions required for a task—no wildcards on * in production unless carefully justified and scoped.
Practical rules
- Start with AWS managed job-function policies, then trim
- Scope
Resourceto specific ARNs—not"*"for sensitive services - Separate prod and sandbox accounts (Organizations preview later)
- Use roles for apps; ban shared user access keys on servers
- Review IAM Access Analyzer findings periodically
Anti-patterns
- Attaching
AdministratorAccessto every developer - Root access keys in CI pipelines
- Public S3 buckets via overly permissive bucket policies (see storage lessons)
Security mindset continues on Cybersecurity.
List users with access keys
# Audit sandbox account — disable unused keys
aws iam generate-credential-report
# After report is ready:
aws iam get-credential-report --output text | headPractice: Perform IAM steps in the IAM Console or with the AWS CLI in a sandbox account only.
Important interview questions and answers
- Q: Least privilege in one sentence?
A: Give identities the minimum permissions needed to perform their job—nothing more. - Q: Why avoid AdministratorAccess for devs?
A: One compromised key or mistaken CLI command can delete entire environments.
Self-check
- Name two least-privilege practices for IAM users.
- Why should applications use roles instead of user access keys?
Pitfall: AdministratorAccess on developers—one typo can delete production.
Interview prep
- Least privilege?
Grant minimum permissions required—avoid AdministratorAccess for daily dev.
- App credentials?
Use IAM roles on EC2/Lambda—not long-lived user access keys on servers.