IAM answers every call in three steps:
Deniedthe start
a policy says Allow
Allowedopened
any policy says Deny
Deniedalways wins
| Policies that apply | Answer |
|---|---|
| none mentions the action | denied |
| one says Allow | allowed |
| one says Allow, another says Deny | denied |
A Deny takes one action away, even when a group allows it. Use it to make one exception without changing what everyone else in the group can do:
json
{
"Version": "2012-10-17",
"Statement": [{
"Effect": "Deny",
"Action": "s3:DeleteObject",
"Resource": "arn:aws:s3:::dragon-photos-2026/*"
}]
}The exception is for one person, so attach it to that user, not the group:
New command
aws iam attach-user-policy
Attaches a policy to one user.
Usageaws iam attach-user-policy --user-name user --policy-arn policy ARN
Example
aws iam attach-user-policy --user-name kai --policy-arn arn:aws:iam::123456789012:policy/NoDelete