Read identity policies and permissions boundaries the way AWS evaluates them, then write least-privilege policies that a checker tests against real requests.
Draft. Not yet reviewed by a second person. The checker covers the parts of IAM these exercises use, and says so when a policy goes beyond them.
Every request to AWS starts denied. It is allowed only if an identity policy has a statement that allows it, nothing anywhere denies it, and, if the principal has a permissions boundary, the boundary allows it too. An explicit Deny always wins, wherever it is.
A statement applies to a request when its action matches, its resource matches and its condition, if any, holds. Action names ignore case and accept * and ?; resources are ARNs and their case matters. NotAction and NotResource match everything except what they list, which makes an Allow with them far broader than it looks.
A condition compares a value from the request, such as aws:SourceIp or a resource tag, with the policy. When the request does not carry that key, a positive operator such as StringEquals does not match, while a negated one such as NotIpAddress does. That last rule is how a network guard rail can deny calls that carry no source IP at all.
The checker here follows AWS's documented evaluation order for identity policies and boundaries in one account. It covers one condition operator with one key per statement; it refuses anything outside that, rather than guessing. Resource policies, organisation policies and session policies are out of scope.
A negated operator matches when the key is missing, so this Deny also blocks calls that carry no source IP. Check that before you rely on such a rule.
Write a least-privilege policy
Let the backup job write, never delete
The nightly backup job uploads files under backups/nightly/ in the backups bucket and needs to list the bucket to check what is already there. It must not read, delete or overwrite anything outside that prefix, and must not touch other buckets.
Hint 1 of 2
Two statements: one for objects under the prefix, one for the bucket itself. Objects and buckets have different ARNs.
Hint 2 of 2
Name each action. A wildcard such as s3:* or s3:Put* also grants things you did not mean.
Least privilege means naming the exact actions and the narrowest resource. The object ARN and the bucket ARN need separate statements.
One solution opens once your policy passes, or after three checks.
Start and stop only your team's instances
The search team's on-call engineers may start and stop any EC2 instance tagged team = search, and nothing else on EC2: not other teams' instances, and never terminate.
Hint 1 of 2
One Allow for the two actions, limited by a condition on the aws:ResourceTag/team key.
Hint 2 of 2
Without the condition, every instance in the account is covered; with ec2:*, so is terminating.
A tag condition scopes one statement to many resources at once. Leaving out `ec2:CreateTags` matters: whoever can retag an instance can move it into their team.
One solution opens once your policy passes, or after three checks.
Read orders, only from the office
A support role may read single orders and query the orders table, but only from the office range 198.51.100.0/24. It may not write, and may not read other tables.
Hint 1 of 2
Name the two read actions and the table's ARN. dynamodb:* or dynamodb:Get* grants more than asked.
Hint 2 of 2
Add an IpAddress condition on aws:SourceIp to the Allow, so requests from elsewhere are simply not allowed.
Putting the network condition on the Allow keeps the policy self-contained. A separate Deny with NotIpAddress also works, but it also blocks calls that carry no source IP.
One solution opens once your policy passes, or after three checks.