How do you implement least-privilege IAM policies and why is it critical?
Least-privilege means granting only the exact permissions needed to perform a task — no more. This limits blast radius if credentials are compromised.
Implementation steps:
- Start with deny-all, add allows: Begin with minimal permissions and add only what’s needed.
- IAM Access Analyzer: Use to identify unused permissions and generate least-privilege policies based on CloudTrail logs.
- Policy conditions: Add
StringEqualsconditions to restrict resources by tag, region, or account. - Permission boundaries: Cap the maximum permissions a principal can have, even if attached policies are more permissive.
"Condition": {
"StringEquals": {
"aws:RequestedRegion": "us-east-1"
}
}