Skip to content

Intermediate · Cloud security basics · topic 29 of 43 · 35 min

Cloud identity and access management

Explanation

In the cloud, identity is the main control: whoever holds an admin login or access key controls the whole account. Protect the root or owner account with MFA and never use it daily, give people and programs roles with least privilege, prefer short-lived role credentials over long-lived access keys, and review permissions regularly.

Why cloud IAM is critical

In a data centre, an attacker needs to get onto your network first. In the cloud, the management console and APIs are on the internet. Anyone with a valid admin password or access key can create servers, read every database and delete backups from anywhere in the world. That is why identity and access management (IAM) is the most important cloud control.

Key words

WordMeaning
Root user / account ownerThe first, all-powerful identity of a cloud account. Use only for a few special tasks
UserAn identity for a person
GroupA set of users that share permissions
RoleA set of permissions that a person or program can take on temporarily
PolicyA document that says which actions are allowed or denied on which resources
Access keyA long-lived ID and secret that programs use to call cloud APIs
Service account / managed identityAn identity for a program, not a person

Reading a policy

In AWS, permissions are JSON policy documents. Each statement has an Effect (Allow or Deny), Actions (what can be done) and Resources (on what). Here is a least-privilege policy that lets an app only read invoice files from one bucket:

json
{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Action": ["s3:GetObject"],
      "Resource": "arn:aws:s3:::invoices-bucket/*"
    }
  ]
}
Allow only GetObject (read a file) and only inside invoices-bucket. "2012-10-17" is the policy language version, not a date you change.
json
{
  "Version": "2012-10-17",
  "Statement": [
    { "Effect": "Allow", "Action": "*", "Resource": "*" }
  ]
}
The opposite: any action on any resource. Full admin. Attached to an app or a developer's everyday account, this is a disaster waiting to happen.

Azure uses role-based access control (Azure RBAC) with built-in roles like Owner, Contributor and Reader, assigned to Microsoft Entra ID users, groups or managed identities at a scope (subscription, resource group or resource). Google Cloud has IAM roles assigned to principals on projects and resources. The ideas are the same.

Good cloud IAM habits

  1. Lock away the root/owner account: strong password, MFA (ideally a hardware key), no access keys, used only for the few tasks that need it.
  2. MFA for every human user, especially admins.
  3. Use single sign-on from the company identity provider so leavers lose access everywhere at once.
  4. Least privilege: start with nothing and add only what is needed. Use built-in "Reader" style roles for people who only look.
  5. Prefer roles with temporary credentials for programs (for example an IAM role on a server, or a managed identity) instead of long-lived access keys.
  6. If access keys must exist: rotate them, never put them in code, and delete unused ones.
  7. Review permissions regularly; cloud tools can show permissions that have not been used for 90 days.
bash
$ aws iam list-access-keys --user-name build-bot
{
    "AccessKeyMetadata": [
        {
            "UserName": "build-bot",
            "AccessKeyId": "AKIAIOSFODNN7EXAMPLE",
            "Status": "Active",
            "CreateDate": "2023-01-09T06:31:10+00:00"
        }
    ]
}
An access key created in 2023 and still active: a candidate for rotation or replacement with a role. (The key ID is AWS's documentation example.)

Common mistakes

  • Using the root account for daily work.
  • Giving developers full admin "to move fast".
  • Access keys in source code, mobile apps or shared spreadsheets.
  • Forgetting service accounts in access reviews; they often have the most power.

Need help?

Stuck on a word or an idea? Search this course, or every course, and jump straight to the explanation or a worked question.

Try:

Watch the lesson

Cloud identity and access management · 1/6

Identity = the cloud perimeter

Cloud consoles and APIs are on the internet. Whoever holds an admin login controls the account.

Prefer a video by a teacher? Find free videos on “AWS IAM best practices roles policies least privilege explained” on YouTube ↗

In real life: A leaked key and a crypto-mining bill

A college student's project pushed an access key for a personal cloud account to a public repository. Within hours, bots found it and started dozens of powerful virtual machines in several regions to mine cryptocurrency. The student woke up to a huge bill. Cloud providers sometimes waive such charges for first incidents, but not always. The fixes: never put keys in code, use MFA on the account, set billing alerts, and give keys only the narrow permissions they need.

Practice (0/3 done)

Task 1 · Question

What should the root or owner account of a cloud account be used for?

Task 2 · Code · Python

Write admin_statements(policy) where policy is a dict like an AWS policy. Return the number of statements with Effect "Allow" whose Action is "*" (or a list containing "*") AND whose Resource is "*" (or a list containing "*").

Task 3 · Code · Python

Write old_keys(keys, today, max_days) where keys is a list of dicts with "id", "status" ("Active" or "Inactive") and "created" (a datetime.date). Return a sorted list of ids of ACTIVE keys older than max_days days.

Quick quiz

Question 1

1.What does a cloud IAM policy define?

Question 2

2.Why are roles with temporary credentials better than access keys for apps?

Question 3

3.Which Azure built-in role lets someone look but not change?

Question 4

4.An access key is found in a public GitHub repo. First step?

Question 5

5.Which identity type is meant for programs, not people?

Read more (free)

Open a question to see the answer and why. The first ones are this topic's own quiz, so try the quiz above before you peek.

What does a cloud IAM policy define?

Answer: Which actions are allowed or denied on which resources

Policies are the permission rules.

Why are roles with temporary credentials better than access keys for apps?

Answer: Credentials expire automatically, so a leak is useful for a short time only

Short-lived credentials shrink the window of misuse.

Which Azure built-in role lets someone look but not change?

Answer: Reader

Reader gives view-only access.

An access key is found in a public GitHub repo. First step?

Answer: Deactivate or rotate the key immediately, then check what it was used for

Kill the key first, then investigate its activity in the cloud logs.

Which identity type is meant for programs, not people?

Answer: Service account or managed identity

Service accounts and managed identities are for workloads.

Which IAM identity gives temporary credentials and is the right choice for a Lambda function?Related

Answer: IAM role

Lambda runs with an execution role; AWS supplies temporary credentials.

From IAM: users, groups, roles and least privilege

Developers may create their own IAM roles, but never more powerful than a set limit. What enforces that limit?Related

Answer: A permissions boundary

A permissions boundary caps the permissions of the users or roles it is set on.

From Identity is the new perimeter

What is least privilege?Related

Answer: Each account gets only the access its job needs

Minimum access limits damage when an account is misused.

From Identity and access management, least privilege and RBAC

What is the difference between Entra roles and Azure roles?Related

Answer: Entra roles manage the directory (users, apps); Azure roles manage Azure resources

Global Administrator is an Entra role; Owner and Contributor are Azure roles. They are separate systems.

From Microsoft Entra ID and Azure RBAC

Pass the quiz (60% or more) or mark this topic as done when you are ready.

Your progress is saved on this device only.

Next steps

  1. 2 more topics in “Cloud security basics” before its exam: Common cloud misconfigurations, Logging and monitoring in the cloud.
  2. Module 7 exam: Cloud security basics · 12 questions · 20 min, without help. 4 topics of this module still to finish first.
  3. Then the next module, Governance, risk and compliance. 43 topics left in the course before the final exam.

← Previous: The shared responsibility model