Security, governance and monitoring

Course 4 · Today your platform gets secrets kept out of sight, logs, a pager, and least privilege

Today

When What Where
0:00Recap: what's still wrong after M2Lecture
0:10IAM deeper, least privilege, Zero Trust, encryption, KMS, secretsLecture
0:45CloudTrail, CloudWatch, alarms, budgetsLecture
1:05Multi-account on paper, from MCO to SRELecture
1:30M3: secret, execution role, logsProject
2:10M3: the pagerProject
2:40M3: the deployer role and its AccessDeniedProject
3:15Check M3, commit, pick your EPITA ideaProject

Puff works. Nobody can trust it yet.

The database password is in plain text in your Git history, and if your app died at 3:00 nobody would know.

Most cloud breaches start with a leaked key that still worked.

A key that lasts forever, or a visitor badge

IAM user

A password and AKIA... keys that never expire. They work until someone notices

IAM role

No credentials of its own. STS hands out temporary ones, worthless within the hour

Humans sign in through SSO and land in a role. Machines get a role attached.

Least privilege, before and after

Before

ssm:* and kms:* on *. It works, and a hacked instance reads and deletes every parameter

After

One action on one resource: ecs:UpdateService on your service only

A cashier's badge opens the till, not the vault.

Game time

Least privilege meter

Open it on the course page

How AWS decides, every single call

  • Start from denyIf nothing allows it, it's refused
  • Explicit deny winsAny "Effect": "Deny" that applies, refused, nothing overrides it
  • Then allowA policy allows it and every guardrail like an SCP agrees

Zero Trust, already in your Puff

Principle Where it shows up
Never trust the networkThe DB is in a private subnet and still needs a password
Verify every requestEvery AWS call is signed and checked by IAM
Short-lived credentialsassume-role gives keys valid one hour, no key on disk
No permanent way inNo SSH, no port 22, containers you replace instead of patching

Every door checks your badge, even the ones deep inside.

Groups, never people

At Alan, engineers sign in to AWS through SSO and access goes to groups. Someone leaves, every AWS access leaves with their company account.

Two Cognito pieces people mix up

User pool

A user directory for your app: sign-up, sign-in, MFA, "log in with Google". Gives back JWT tokens

Identity pool

Swaps a token for temporary AWS credentials, when the browser talks to AWS directly

Federation for employees, Cognito for customers. You never store a password yourself.

At rest, service by service

Service At rest
S3Encrypted by default, switch to your own KMS key if you want
EBSPer disk, or "encryption by default" for the whole Region
RDSChosen at creation, can't be switched on later
Parameter StoreSecureString parameters, encrypted with a KMS key

Default to encrypted for every database, even the "temporary" ones.

Envelope encryption in four steps

  • Ask for a data keyKMS returns it twice: in plaintext and encrypted under your KMS key
  • Encrypt locallyFast, any size, then throw the plaintext key away
  • Store them togetherThe encrypted data key sits right next to the encrypted data
  • Read it backSend the encrypted key to KMS, it checks and returns the plaintext key

KMS disables your key. What happens to every file encrypted with it?

Where secrets never go

  • Never in GitBots scan public repos within minutes
  • Never in user dataAnyone with EC2 read access can pull it back
  • Never in a container imageImages get pushed, pulled and shared
  • Readable only by who needs itOne identity, one path, one action

Two places to keep them

Secrets Manager SSM Parameter Store
Built forSecretsSettings, including SecureString
Rotates passwords for youYes, built in for RDSNo, you build it
CostPaid per secret per monthStandard parameters are free
On FlociAvailable, used in M3Available

In a real company: DB credentials in Secrets Manager, plain settings in Parameter Store.

Game time

Secret hunt

Open it on the course page

One account per environment, like separate apartments

The strongest wall AWS has. A mistake in staging can't delete production.

Classic SCPs

  • Stay in EuropeDeny any action outside eu-central-1 and eu-west-3
  • Keep the recordingDeny cloudtrail:StopLogging and DeleteTrail
  • Nobody leavesDeny leaving the organization
  • SSO onlyDeny creating IAM users with access keys

An SCP denies s3:DeleteBucket on the Prod OU. A prod admin tries anyway. What happens?

And why can't the account's admin fix it from inside?

A 200-person health startup, everything in one account. Draw the target layout.

OU tree, where logs go, where backups go, SSO groups, two day-one SCPs.

Game time

One company, many accounts

Open it on the course page

CloudTrail, the security camera of your account

Who called, what action, on which resource, from which IP, when, and whether it worked. Console clicks too.

Game time

CloudTrail detective

Open it on the course page

Two 5xx metrics, two different stories

HTTPCode_Target_5XX_Count HTTPCode_ELB_5XX_Count
Who made the 5xxYour Flask app answered 500The ALB itself, no usable answer
Typical causeA bug, the DB refusing connectionsContainer down, timeouts, no healthy target
What it tells youYour code is failingYour service is gone

An alert that wakes someone up should mean users are hurting.

A CPU at 90% that serves every request in 50 ms is a healthy machine doing its job.

Game time

Alarm tuner

Open it on the course page

In a data center

Job Platform 2.0 On AWS
IdentitiesActive Directory, LDAPIAM
Encryption keysAn HSM, a hardware safeKMS
MonitoringNagios, ZabbixCloudWatch
Security logsA SIEMCloudTrail

Same jobs, already wired to every service.

A crypto miner breaks nothing. It just costs money.

An AWS Budgets alert at 50%, 80% and 100% is your low-fuel light. Every new account gets one before its first workload.

Running it is four jobs

  • WatchAlarms that mean "act now", and nothing else
  • RespondSomeone on call, a known path from alert to fix
  • Repair and learnFix it, write it down, change something so it doesn't come back
  • MaintainPatch, upgrade, rotate secrets, test that backups restore

Two ways to run it

Platform 2.0: ITIL Platform 3.0: DevOps and SRE
Who runs itA separate operations teamThe team that builds it
ChangesApproved in a change boardSmall, automated, reversible, many per day
The promiseAn SLA in a contractAn SLO with an error budget
After an incidentFind who made the mistakeBlameless postmortem
Repetitive workTicketsCalled toil, automated away
Actionable or deleted

At Alan, if the person paged can only acknowledge and go back to sleep, the alert gets fixed or deleted.

Your defense includes a tiny on-call shift

I break something in your platform. You have two minutes to find it with today's tools.

Hands-on

Project M3: secrets, logs, a pager, and least privilege

✅ ./checks/check.sh M3 all PASS, a page and the deployer's AccessDenied in NOTES.md

Steps on the course page

Game time

Today's quiz

Open it on the course page

Your CPU alarm fired at 3am, and nobody using your app noticed. What would you change?

Everything from today is on the course page.