SECURITY ENGINEERING · PART 10 · CLOUD SECURITY · IDENTITY · 137 OF 229

Cloud IAM Security: Roles and Least Privilege

In the cloud, identity is the perimeter: permissions decide what any attacker who gets in can actually do. This episode covers cloud IAM for security: principals, policies and roles, how AWS, Azure and GCP model access, why you use roles not long-lived keys, least privilege in practice, how permissions are actually evaluated (allow, deny, boundaries), and the common IAM mistakes that turn a foothold into a breach.

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 9
  9. 10
  10. 11
  11. 12
  12. 13
  13. 14
  14. 15
  15. 16
  16. 17
  17. 18
  18. 19
  19. 20
  20. 21
  21. 22
  22. 23
  23. 24
  24. 25
  25. 26
  26. 27
  27. 28
  28. 29
  29. 30
  30. 31
  31. 32
  32. 33
  33. 34
  34. 35
  35. 36
  36. 37
  37. 38
  38. 39
  39. 40
  40. 41
  41. 42
  42. 43
  43. 44
  44. 45
  45. 46
  46. 47
  47. 48
  48. 49
  49. 50
  50. 51
  51. 52
  52. 53
  53. 54
  54. 55
  55. 56
  56. 57
  57. 58
  58. 59
  59. 60
  60. 61
  61. 62
  62. 63
  63. 64
  64. 106
  65. 107
  66. 108
  67. 109
  68. 110
  69. 111
  70. 112
  71. 113
  72. 114
  73. 115
  74. 116
  75. 117
  76. 118
  77. 119
  78. 120
  79. 121
  80. 122
  81. 123
  82. 124
  83. 125
  84. 126
  85. 127
  86. 128
  87. 129
  88. 130
  89. 131
  90. 132
  91. 133
  92. 134
  93. 135
  94. 136
  95. 137
  96. 138
  97. 139
  98. 140
  99. 141
  100. 142
  101. 143
  102. 144
1 / 10

Press play to hear the narration, or step through at your own pace.

Key takeaways

  • Identity is the perimeter
  • roles not keys
  • least privilege, no wildcards
  • explicit deny wins
  • govern machine identity too

Notes

The pieces

The building blocks are the same on every cloud, even if the names differ. A principal is who is acting: a user, a role, a service account, a workload. A policy is the set of rules, allowing or denying specific actions on specific resources. A resource is the thing acted on: a bucket, a database, a function. Every single API call is evaluated against the applicable policies before it is allowed. Once you see IAM as who may do what action on which resource, the providers all look alike underneath.

IAM building blocks
  • principal: who is acting (user, role, service account, workload)
  • policy: the rules, allow or deny, on which actions and resources
  • resource: the thing acted on (bucket, database, function)
  • every API call is checked against the policies

Roles, not keys

The most important habit is to use roles, not long-lived access keys. A static key sits around waiting to leak, which the last episode showed is a top breach cause. A role is assumed instead: the principal proves who it is and receives short-lived temporary credentials for a specific job. Workloads use their own identity to assume a role, so there is no stored key, the workload-identity idea from DevSecOps. People log in and assume roles per task. The whole point: nothing static to steal.

Why roles win
  • a long-lived access key is a static secret that leaks
  • a role is assumed: you get short-lived temporary credentials
  • workloads use their identity to assume a role; no stored key
  • users log in and assume roles per task
  • nothing static to steal

Least privilege

Least privilege is the core principle: grant only the permissions actually needed. Start from zero and add only what a workload demonstrably needs, rather than starting broad and never trimming. Avoid wildcards like action-star and resource-star, and admin roles for routine work. Scope permissions to specific actions, resources and conditions. Use the providers' access analyzers to remove granted-but-unused permissions. And keep separate roles per job and environment, so one does not become a skeleton key.

Least privilege in practice
  • start from zero; add only what is needed
  • avoid wildcards (Action: *, Resource: *) and admin
  • scope to specific actions, resources, conditions
  • use access analyzers to find unused permissions and trim them
  • separate roles per job and per environment

How it evaluates

You need to know how a request is actually decided, because it is not obvious. By default everything is denied; you need an explicit allow for an action to succeed. But an explicit deny always wins and overrides any allow, which makes deny useful for hard guardrails. On top of that, org-level guardrails cap what is even possible in an account regardless of its own policies, and permission boundaries limit the maximum a role can have. This layered evaluation lets you reason about why a call was allowed or blocked.

The evaluation logic
  • default: deny (implicit)
  • an explicit allow is needed to permit an action
  • an explicit deny always wins, overriding any allow
  • guardrails (SCPs, org policies) can cap what is even possible
  • permission boundaries limit a role's maximum

Across the clouds

The three big clouds model this with different names. AWS has IAM users and roles, JSON policies, and a token service for temporary credentials. Azure uses its directory identities with role-based access control, assigning roles at scopes like a subscription or resource group. Google Cloud binds roles to members on resources, with service accounts for workloads. The vocabulary differs, but the model is identical: principal, policy and resource produce an allow or deny. Learn it once and you can read any of them.

Provider differences
  • AWS: IAM users/roles, JSON policies, STS for temp creds
  • Azure: Entra ID identities, RBAC role assignments on scopes
  • GCP: IAM members, roles bound on resources, service accounts
  • same idea: principal + policy + resource -> allow/deny

Human and machine

One thing people miss: most cloud identities are not people. Human identities are your engineers, ideally arriving through single sign-on with MFA and assuming roles. But machine identities, the roles and service accounts that workloads and pipelines use, vastly outnumber humans in any real account. And they are often the most over-permissioned and least monitored, because nobody logs in as them to notice. A large share of cloud risk hides in machine identity, so govern it as carefully as human access.

Two kinds of identity
  • human: engineers, via SSO and MFA, assuming roles
  • machine: workloads, service accounts, CI pipelines
  • machine identities vastly outnumber humans, and are often over-permissioned and unmonitored
  • govern both; machine identity is where the risk hides

Common mistakes

Mistakes, the IAM half of the last episode's breaches. Long-lived access keys instead of assumed roles. Wildcard and admin permissions handed out because they are easy. One powerful role reused across many services, so compromising anything compromises everything. Over-permissioned machine identities that nobody watches. No MFA on human users or the root account. And never reviewing permissions, so grants accumulate forever. Each is exactly what the next episode's attackers look for.

Avoid these
  • long-lived access keys instead of roles
  • wildcard and admin permissions everywhere
  • one powerful role reused across everything
  • over-permissioned machine identities
  • no MFA on users or root
  • never trimming permissions

Say it like this

In the interview: identity is the perimeter, so IAM is the core control. I use assumed roles rather than long-lived keys, so credentials are short-lived and nothing static leaks. I apply least privilege: scope to specific actions and resources, avoid wildcards and admin, and use access analyzers to remove unused permissions. I enforce MFA and protect root, and use org guardrails and permission boundaries as hard caps. And I govern machine identities as carefully, because they hide most of the risk.

In the interview
  • "Identity is the perimeter.
  • Roles not long-lived keys, so credentials are short-lived.
  • Least privilege: scope to specific actions and resources, no wildcards, trim
  • unused with access analyzers.
  • MFA on humans, guardrails and boundaries as caps, and I
  • govern machine identity too."

Interview questions

Q1Why is identity the perimeter in cloud security?

Because the cloud has no network edge to hide behind: every action is an API call authorised by IAM. What a compromised identity is permitted to do determines the blast radius, so permissions, not network location, are the main control.

Q2What are the core building blocks of cloud IAM?

A principal (the actor: user, role, service account or workload), a policy (allow or deny rules for actions on resources), and a resource (the thing acted on). Every API call is evaluated against applicable policies to produce an allow or deny decision.

Q3Why use roles instead of long-lived access keys?

A long-lived key is a static secret that can leak and is often over-permissioned. A role is assumed to obtain short-lived temporary credentials, and workloads can assume roles using their own identity, so there is no stored key to steal.

Q4What is least privilege in cloud IAM?

Granting only the permissions an identity actually needs, scoped to specific actions, resources and conditions, starting from zero rather than broad. Access analyzers help identify and remove unused permissions, and separate roles per job and environment limit blast radius.

Q5How is a cloud IAM request evaluated?

By default everything is denied; an explicit allow is required to permit an action, and an explicit deny always overrides any allow. Organisation guardrails (such as SCPs) and permission boundaries further cap what an identity can do regardless of its own policies.

Q6How do AWS, Azure and GCP IAM compare?

The model is the same, principal plus policy plus resource producing allow or deny, with different names: AWS uses IAM users/roles and JSON policies with STS; Azure uses directory identities and RBAC assignments on scopes; GCP binds roles to members on resources with service accounts.

Q7Why are machine identities a major cloud risk?

Service accounts and workload roles vastly outnumber human users, are frequently over-permissioned, and are rarely monitored because no one logs in as them. A large share of cloud compromise exploits machine identities, so they need least privilege and short-lived credentials too.

Q8What are permission boundaries and guardrails?

A permission boundary limits the maximum permissions an identity can have, even if its policies grant more. Guardrails such as AWS Service Control Policies or organisation policies cap what any account can do, providing org-wide limits that individual policies cannot exceed.