Skip to main content

Lesson 7 of 10

Identity & Access Management (IAM) in Cloud

Cloud IAM (Identity and Access Management) is one of the most critical and most frequently misconfigured areas of cloud security. Overly permissive IAM policies and credential mismanagement are leading causes of cloud security breaches.

50 minBy Priygop Editorial TeamUpdated 2026Peer Reviewed & Verified

AWS IAM Core Concepts

AWS IAM Core Concepts
# AWS IAM - who can do what to which resources

# Principals: IAM Users, IAM Roles, AWS Services, External identities
# Resources: S3 buckets, EC2 instances, RDS databases, Lambda functions
# Actions: s3:GetObject, ec2:DescribeInstances, iam:CreateUser
# Conditions: IP range, MFA required, time restrictions

# Example IAM Policy (JSON) - least privilege principle
{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "S3ReadBucketOnly",
            "Effect": "Allow",
            "Action": [
                "s3:GetObject",
                "s3:ListBucket"
            ],
            "Resource": [
                "arn:aws:s3:::my-specific-bucket",
                "arn:aws:s3:::my-specific-bucket/*"
            ],
            "Condition": {
                "Bool": {
                    "aws:MultiFactorAuthPresent": "true"   // Require MFA
                },
                "IpAddress": {
                    "aws:SourceIp": "203.0.113.0/24"       // Office IP only
                }
            }
        }
    ]
}

# BAD policy (common mistake - too permissive):
{
    "Effect": "Allow",
    "Action": "*",           # ALL actions on ALL services
    "Resource": "*"          # ALL resources in the account
}
# This is effectively granting root access to AWS

IAM Security Best Practices

  • Root account: Only use for account setup and billing. Immediately create an IAM admin user. Enable MFA on root. Do not create access keys for root - never use root programmatically
  • IAM roles over users for services: EC2 instances, Lambda functions, and containers should use IAM roles - temporary credentials automatically rotated by AWS; never hard-code access keys in code
  • Least privilege: Start with no permissions, add only what is required. Use IAM Access Analyzer to identify overly permissive policies
  • Credential rotation: Rotate IAM user access keys every 90 days or on any potential exposure. Delete inactive users and keys
  • CloudTrail: Enable AWS CloudTrail in all regions - logs every API call to S3. This is your audit log; essential for incident response
  • Service Control Policies (SCPs): Organization-level guardrails that apply to all accounts. Prevent any account from creating IAM users, disabling CloudTrail, or accessing regions you don't use

Finding IAM Misconfigurations

Finding IAM Misconfigurations
# AWS IAM security audit commands

# List all IAM users
aws iam list-users

# Find users with no MFA
aws iam list-users | jq -r '.Users[].UserName' | while read user; do
    mfa=$(aws iam list-mfa-devices --user-name "$user" | jq -r '.MFADevices | length')
    if [ "$mfa" -eq 0 ]; then echo "No MFA: $user"; fi
done

# Find access keys older than 90 days
aws iam generate-credential-report
aws iam get-credential-report --output text --query Content | base64 -d

# Check for overly permissive policies
aws iam list-policies --scope Local | jq '.Policies[].PolicyName'
# For each policy:
aws iam get-policy-version --policy-arn <ARN> --version-id v1 | jq '.PolicyVersion.Document'

# Automated audit tools
pip install prowler
prowler aws -p iam     # Full IAM audit
pip install cloudsplaining  # IAM permissions risk analysis

Common Mistakes

  • Hard-coding AWS credentials in source code - credentials committed to Git are indexed by GitHub and scanned by bots within seconds; use IAM roles for AWS resources and environment variables/secrets managers for external services
  • Not deleting unused IAM users and access keys - dormant credentials are frequently compromised in spear phishing and used when no one is monitoring them
  • Using the same IAM role for different environments - production environments have stricter security requirements; use separate roles for dev/staging/production with appropriate permission differences

Tip

Tip

Practice Identity Access Management IAM in Cloud in small, isolated examples before integrating into larger projects. Breaking concepts into small experiments builds genuine understanding faster than reading alone.

Diagram
Loading diagram…

The foundational security model: Confidentiality (privacy), Integrity (trust), and Availability (uptime).

Practice Task

Note

Practice Task - (1) Write a working example of Identity Access Management IAM in Cloud from scratch without looking at notes. (2) Modify it to handle an edge case (empty input, null value, or error state). (3) Share your solution in the Priygop community for feedback.

Quick Quiz

Common Mistake

Warning

A common mistake with Identity Access Management IAM in Cloud is skipping edge case testing - empty inputs, null values, and unexpected data types. Always validate boundary conditions to write robust, production-ready cybersecurity code.

Key Takeaways

  • Cloud IAM (Identity and Access Management) is one of the most critical and most frequently misconfigured areas of cloud security.
  • Root account: Only use for account setup and billing. Immediately create an IAM admin user. Enable MFA on root. Do not create access keys for root - never use root programmatically
  • IAM roles over users for services: EC2 instances, Lambda functions, and containers should use IAM roles - temporary credentials automatically rotated by AWS; never hard-code access keys in code
  • Least privilege: Start with no permissions, add only what is required. Use IAM Access Analyzer to identify overly permissive policies

Hands-on Practice Tools for this Course

Test what you learn using these free in-browser developer utilities (no signup required).

All 40+ Tools

Topics in This Module

0/10 done