TwiceToldby Develoker
ConceptsSystem designLabsCheat sheetsAbout

Develoker makes free tools for learning to build software. TwiceTold explains each idea twice, as an everyday analogy and the real thing; CloudArch lets you design cloud systems and put load on them.

About ยท Labs ยท Cheat sheets ยท Learning paths

โ† 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.
Who are you, and may you?Step 4 of 4
๐Ÿง‘โ€๐Ÿ’ผMia๐Ÿ‘‘Building ownerMFA, no keys๐Ÿ’‚Door guardAllow๐Ÿ—„๏ธ Files room
  1. Mia walks up to the files room and asks the guard to let her in, holding up her staff badge.
  2. First question, who are you? The guard checks the badge is real and really belongs to Mia.
  3. Second question, may you? The guard reads the rules written down for Mia. They say yes, so the door opens.
  4. The owner's master key opens every room, so it stays locked in the safe and comes out only for rare jobs.
Default deny, and deny winsStep 4 of 4
๐Ÿง‘โ€๐Ÿ’ผMiaYes cardAllow s3:* on *๐Ÿ’‚Door guardAllowNo cardDeny payroll/*๐Ÿ—„๏ธ Files room๐Ÿ” Safe room
  1. Mia is new and has no permission cards yet. She asks for the files room, and the guard says no, because nothing says yes.
  2. She gets a card that says yes to reading the files room. Now the guard lets her in.
  3. 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.
  4. The no card only covers the safe room, so the files room still opens for her.
Cards on people, cards on doorsStep 4 of 4
๐Ÿข Our building๐Ÿฌ Building next door๐Ÿง‘โ€๐Ÿ’ผMiacard: read files๐Ÿ’‚Door guard๐Ÿ—„๏ธ Files roomdoor: Leo may read๐Ÿง‘โ€๐Ÿ”งLeocard: read files
  1. Mia's card is clipped to her badge and says she may read the files room. Inside one building, that one yes is enough.
  2. 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.
  3. Leo's building gives him a card saying he may read our files room. With a yes on both sides, the door opens.
  4. Leo tries to throw a file away. The door card only says read, so the answer is no, whatever his own card says.
Borrowing a roleStep 6 of 6
๐Ÿง‘โ€๐Ÿ’ผMiapass expired๐Ÿ›Ž๏ธVest desk๐ŸฆบAuditor vesttag: our building๐Ÿ—„๏ธ Files room๐Ÿค–Cleaning robotinstance profile
  1. Mia's own card says she may ask for vests. She goes to the vest desk and asks to borrow the Auditor vest.
  2. 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.
  3. The desk hands her the vest and a day pass that works for one hour.
  4. While she wears the vest, guards read the vest's card, not hers. It lets her read the files room.
  5. After an hour the day pass stops working on its own. There's nothing to take back.
  6. 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.
A key that never expiresStep 4 of 4
๐Ÿง‘โ€๐Ÿ’ปSam's programkey deactivated๐Ÿ“‚ Shared folder๐Ÿ•ต๏ธStrangeracting as ci-bot๐Ÿ—„๏ธ Files room
  1. Sam's program opens doors with a spare key copied from Sam's. The key never expires, and its card says every room.
  2. One day Sam leaves a copy of the key in the shared folder by mistake.
  3. A stranger finds it and walks in as Sam's program. Because the card says every room, the stranger can even throw files away.
  4. 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.
The default credentials provider chainStep 5 of 5
โ˜•Your Java approle creds cachedStart-up note๐Ÿงฅ Coat pockets๐Ÿ—‚๏ธ Pass file at home๐ŸชŸVest desk window๐Ÿ—„๏ธ Files room
  1. Your app needs a pass. First it checks for a note handed to it at start-up. There isn't one.
  2. Next, its coat pockets. Empty here, though in a temp worker's job the vest's pass would usually be waiting right there.
  3. Then the pass file at home. On your laptop it would hold your own pass, but this machine has none.
  4. Finally it goes to the vest desk window of the machine it runs on, and gets a day pass for the machine's vest.
  5. 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.