โ Back to AWS IAM: users, roles and policies
๐ชช AWS IAM: users, roles and policies: cheat sheet
๐จ The analogyAn office with a guard at every door who reads your permission cards, and day passes instead of forever keys.
๐ The regular explanationHow AWS decides who may call which API on which resource. Principals authenticate, then JSON policies are evaluated with default deny and explicit deny winning, and roles hand out short-lived credentials through STS.
- Mia walks up to the files room and asks the guard to let her in, holding up her staff badge.
- First question, who are you? The guard checks the badge is real and really belongs to Mia.
- Second question, may you? The guard reads the rules written down for Mia. They say yes, so the door opens.
- The owner's master key opens every room, so it stays locked in the safe and comes out only for rare jobs.
- Mia is new and has no permission cards yet. She asks for the files room, and the guard says no, because nothing says yes.
- She gets a card that says yes to reading the files room. Now the guard lets her in.
- Someone swaps her card for one that says yes to every room. But a card saying never the safe room is pinned up too, and a no beats every yes.
- The no card only covers the safe room, so the files room still opens for her.
- Mia's card is clipped to her badge and says she may read the files room. Inside one building, that one yes is enough.
- A card is taped to the files room door saying Leo from next door may read. Leo walks over, but his own building never said he could go, so the guard says no.
- Leo's building gives him a card saying he may read our files room. With a yes on both sides, the door opens.
- Leo tries to throw a file away. The door card only says read, so the answer is no, whatever his own card says.
- Mia's own card says she may ask for vests. She goes to the vest desk and asks to borrow the Auditor vest.
- The desk reads the tag on the vest, which says who may borrow it. Mia works in our building, so she's on the list.
- The desk hands her the vest and a day pass that works for one hour.
- While she wears the vest, guards read the vest's card, not hers. It lets her read the files room.
- After an hour the day pass stops working on its own. There's nothing to take back.
- The cleaning robot has a vest of its own. The desk hands it a fresh day pass before the old one runs out, and nobody ever gives it a key.
- Sam's program opens doors with a spare key copied from Sam's. The key never expires, and its card says every room.
- One day Sam leaves a copy of the key in the shared folder by mistake.
- A stranger finds it and walks in as Sam's program. Because the card says every room, the stranger can even throw files away.
- Only when someone notices and changes the lock does the copy stop working. A day pass found in the street would have stopped within a few hours at most.
- Your app needs a pass. First it checks for a note handed to it at start-up. There isn't one.
- Next, its coat pockets. Empty here, though in a temp worker's job the vest's pass would usually be waiting right there.
- Then the pass file at home. On your laptop it would hold your own pass, but this machine has none.
- Finally it goes to the vest desk window of the machine it runs on, and gets a day pass for the machine's vest.
- With the pass in hand, the app opens the files room. Nobody wrote a key into its code.
๐งฉ Key questions
- Mia has a card saying yes to every room, and another card saying never the safe room. What happens at the safe room door?
- The guard says no, because a no beats every yes. The guard looks for any no first. Order doesn't matter, and no yes can outvote it.
- A new worker has a badge but no permission cards at all. What can they open?
- Nothing, unless a card says yes. Proving who you are only gets you to the guard. Getting in needs a card that says yes.
- Leo from the building next door wants to read our files room. The door card names him. What else does he need?
- A card from his own building saying he may. Between buildings, both sides must say yes, so neither can open the other's rooms alone.
- Why is a day pass from the vest desk safer than a spare key copied for a program?
- A lost day pass stops working on its own soon, while a spare key works until someone changes the lock. Both can be lost, but a lost day pass is only useful for a short while.
- Your Java app, with no pass written in its code, runs on a machine wearing a vest. Where does it get its pass?
- It checks its usual places, finds nothing, and gets a day pass from the vest desk window. The same app finds your own pass on a laptop and the vest's pass in the cloud, with no changes.