
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:00 | Recap: what's still wrong after M2 | Lecture |
| 0:10 | IAM deeper, least privilege, Zero Trust, encryption, KMS, secrets | Lecture |
| 0:45 | CloudTrail, CloudWatch, alarms, budgets | Lecture |
| 1:05 | Multi-account on paper, from MCO to SRE | Lecture |
| 1:30 | M3: secret, execution role, logs | Project |
| 2:10 | M3: the pager | Project |
| 2:40 | M3: the deployer role and its AccessDenied | Project |
| 3:15 | Check M3, commit, pick your EPITA idea | Project |

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.
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 network | The DB is in a private subnet and still needs a password |
| Verify every request | Every AWS call is signed and checked by IAM |
| Short-lived credentials | assume-role gives keys valid one hour, no key on disk |
| No permanent way in | No SSH, no port 22, containers you replace instead of patching |
Every door checks your badge, even the ones deep inside.

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 |
|---|---|
| S3 | Encrypted by default, switch to your own KMS key if you want |
| EBS | Per disk, or "encryption by default" for the whole Region |
| RDS | Chosen at creation, can't be switched on later |
| Parameter Store | SecureString 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 for | Secrets | Settings, including SecureString |
| Rotates passwords for you | Yes, built in for RDS | No, you build it |
| Cost | Paid per secret per month | Standard parameters are free |
| On Floci | Available, used in M3 | Available |
In a real company: DB credentials in Secrets Manager, plain settings in Parameter Store.

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 outsideeu-central-1andeu-west-3
Keep the recordingDenycloudtrail:StopLoggingandDeleteTrail
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.

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.
Two 5xx metrics, two different stories
HTTPCode_Target_5XX_Count | HTTPCode_ELB_5XX_Count | |
|---|---|---|
| Who made the 5xx | Your Flask app answered 500 | The ALB itself, no usable answer |
| Typical cause | A bug, the DB refusing connections | Container down, timeouts, no healthy target |
| What it tells you | Your code is failing | Your 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.
In a data center
| Job | Platform 2.0 | On AWS |
|---|---|---|
| Identities | Active Directory, LDAP | IAM |
| Encryption keys | An HSM, a hardware safe | KMS |
| Monitoring | Nagios, Zabbix | CloudWatch |
| Security logs | A SIEM | CloudTrail |
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 it | A separate operations team | The team that builds it |
| Changes | Approved in a change board | Small, automated, reversible, many per day |
| The promise | An SLA in a contract | An SLO with an error budget |
| After an incident | Find who made the mistake | Blameless postmortem |
| Repetitive work | Tickets | Called toil, automated away |

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

Your CPU alarm fired at 3am, and nobody using your app noticed. What would you change?
Everything from today is on the course page.
