Courses / Cloud and DevOps Interview Prep / Chapter 9
Module 6 · Security and cost · Chapter 9 of 13
Security, Secrets and the Software Supply Chain
Builds on Scripts and Git for Safe Change, CI/CD Pipelines: Verify, Release Gradually, Roll Back and Kubernetes in Production: Debugging Pods, Services and Rollouts. Next up: Cost and FinOps: Seeing, Shaping and Guarding the Bill.
Part 1 · Least privilege on AWS
Roles, not keys, and only what the job needs
A single over-wide role, a key left in a repository or a dependency nobody checked can hand an attacker a whole cloud account.
Least privilege means a principal gets the actions and resources its job needs and nothing more. A principal is whatever makes a request: a person, a service or a pipeline job. On AWS, a principal can authenticate with a long-lived access key (a key pair that stays valid until someone deletes it) or by assuming an IAM role, which hands out temporary credentials that expire. A leaked access key keeps working until it is found. A leaked role session stops working when it expires, which is why the pipelines chapter deployed by assuming a role instead of storing keys.
Least privilege has two halves. The first is scope: name the specific actions (s3:GetObject, not s3:*) and the specific resources (one bucket, not every bucket). The second is conditions: attach limits such as which service a role may be passed to, or which network a call must come from. A policy written this way is longer than "Action": "*". The benefit shows up when something goes wrong: a stolen deploy role can touch only what the deploy needed.