Skip to content

AWS IAM — Identity and Access Management

AWS IAM — Identity and Access Management

Section titled “AWS IAM — Identity and Access Management”

AWS Identity and Access Management (IAM) is the security foundation of AWS. It controls who (authentication) can do what (authorization) on which AWS resources.

In Azure terms: IAM = combination of Microsoft Entra ID (authentication) + Azure RBAC (authorization).

ConceptDescription
IAM UserA person or application with permanent credentials (username + password or access keys)
IAM GroupA collection of IAM users — assign policies to the group, not individual users
IAM RoleA set of permissions assumed temporarily — used by services, EC2, Lambda, cross-account
IAM PolicyA JSON document defining Allow or Deny permissions for actions on resources
Access KeyProgrammatic credential (Key ID + Secret) for CLI/API access

Policies are JSON documents with a specific structure:

{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"s3:GetObject",
"s3:PutObject"
],
"Resource": "arn:aws:s3:::my-bucket/*"
}
]
}
FieldOptionsMeaning
EffectAllow or DenyWhether to permit or block
Actione.g., s3:GetObject, ec2:*API operations affected
ResourceARN or *Which resources the policy applies to
ConditionOptionalExtra conditions (IP, MFA, time)
TypeDescription
AWS ManagedPre-built by Amazon (e.g., AmazonS3ReadOnlyAccess)
Customer ManagedCustom policies you create and maintain
Inline PolicyDirectly embedded in a user, group, or role (not reusable)
Resource-basedAttached to a resource (e.g., S3 bucket policy, Lambda function policy)
Permission BoundaryMaximum permissions an entity can have
SCP (Service Control Policy)Organization-level guard-rails via AWS Organizations

Roles are the preferred way to grant permissions to AWS services:

  • EC2 Instance Role — Allows an EC2 instance to call S3, DynamoDB, etc. without storing credentials
  • Lambda Execution Role — Grants Lambda permission to write CloudWatch logs, access DynamoDB, etc.
  • Cross-Account Role — Allow users in Account A to assume a role in Account B
  • Federated Identity — Allow users from an external identity provider (Okta, Active Directory) to assume roles
  1. Never use the root account — Create IAM users immediately and lock the root account
  2. Enable MFA — Require MFA for all human users, especially privileged ones
  3. Use roles, not access keys — Avoid long-lived credentials; use instance roles and OIDC
  4. Principle of least privilege — Grant only the permissions needed for the job
  5. Rotate credentials regularly — Rotate access keys and review unused permissions
  6. Use IAM Access Analyzer — Detect over-permissive policies and external access
  7. Enable CloudTrail — Log all API calls for audit and compliance
PolicyDescription
AdministratorAccessFull access to all AWS services (use sparingly)
PowerUserAccessFull access except IAM management
ReadOnlyAccessRead-only access to all services
AmazonS3FullAccessFull S3 access
AmazonEC2ReadOnlyAccessRead-only EC2 access
AWSLambdaBasicExecutionRoleWrite logs to CloudWatch (for Lambda)
FeatureAWS IAMAzure RBAC
Identity unitUser / Group / RoleUser / Group / Service Principal / Managed Identity
Permissions modelPolicies (JSON)Role Definitions (Actions/DataActions)
Service identityIAM RoleManaged Identity
Root equivalentRoot accountGlobal Administrator
Cross-accountCross-account RolesAzure Lighthouse / Guest access
Audit logCloudTrailAzure Activity Log / Entra Audit Logs
Terminal window
# List all IAM users
aws iam list-users
# Create a new IAM user
aws iam create-user --user-name devuser
# Attach a managed policy to a user
aws iam attach-user-policy \
--user-name devuser \
--policy-arn arn:aws:iam::aws:policy/AmazonS3ReadOnlyAccess
# Create an IAM role for EC2
aws iam create-role \
--role-name ec2-s3-role \
--assume-role-policy-document file://trust-policy.json
# Get the current caller identity
aws sts get-caller-identity