AWS IAM: Identity and Access Control
AWS Identity and Access Management (IAM) is the foundation of security in the AWS Cloud. It controls who (identity) can do what (permissions) on which resources (access control). Understanding IAM is essential for building secure, compliant, and well-architected systems.
Core Concepts
IAM is built around a few key building blocks. Getting comfortable with these terms will make everything else easier to reason about.
Principals
A principal is an entity that can make a request to AWS. This includes:
- Root user — the account owner with unrestricted access (avoid daily use).
- IAM users — long-lived identities for people or applications.
- IAM roles — temporary identities assumed by users, services, or federated identities.
- Federated identities — users authenticated via an external identity provider (SAML, OIDC).
Authentication vs. Authorization
- Authentication verifies who you are (credentials, access keys, tokens).
- Authorization determines what you're allowed to do (policies).
IAM Policies
Policies are JSON documents that define permissions. They are the heart of authorization in AWS.
Policy Types
| Type | Attached To | Purpose |
|---|---|---|
| Identity-based | Users, groups, roles | Grant permissions to a principal |
| Resource-based | Resources (e.g., S3 buckets) | Grant cross-account or service access |
| Permissions boundaries | Users, roles | Set the maximum permissions |
| Service Control Policies (SCPs) | AWS Organizations | Guardrails across accounts |
Anatomy of a Policy
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "AllowReadOnlyS3",
"Effect": "Allow",
"Action": [
"s3:GetObject",
"s3:ListBucket"
],
"Resource": [
"arn:aws:s3:::my-app-bucket",
"arn:aws:s3:::my-app-bucket/*"
],
"Condition": {
"IpAddress": {
"aws:SourceIp": "203.0.113.0/24"
}
}
}
]
}
Key elements:
-
Effect —
AlloworDeny. - Action — the API operations being granted or denied.
- Resource — the ARNs the statement applies to.
- Condition — optional rules that refine when the policy is in effect.
How IAM Evaluates Requests
When a principal makes a request, AWS evaluates all applicable policies using this logic:
- Default deny — every request is implicitly denied by default.
-
Explicit deny — an explicit
Denyalways wins and cannot be overridden. -
Explicit allow — a matching
Allowgrants access if noDenyapplies.
In practice: Explicit Deny > Explicit Allow > Implicit Deny.
IAM Roles: Temporary Credentials
Roles are the recommended way to grant permissions because they issue short-lived credentials instead of long-term access keys.
Common use cases:
- EC2 instance profiles — grant applications on an instance access to AWS services.
- Cross-account access — allow one account to assume a role in another.
- Service roles — let AWS services (e.g., Lambda) act on your behalf.
Example trust policy allowing Lambda to assume a role:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"Service": "lambda.amazonaws.com"
},
"Action": "sts:AssumeRole"
}
]
}
Best Practices
Following these guidelines dramatically reduces your security risk:
- Enforce least privilege — grant only the permissions required, then tighten over time.
- Use roles over users — prefer temporary credentials for workloads.
- Enable MFA — require multi-factor authentication for all human users.
- Rotate credentials — regularly rotate access keys, or eliminate them entirely.
- Avoid the root user — lock it down with MFA and use it only for account-level tasks.
- Use permissions boundaries and SCPs — set organizational guardrails.
- Audit with tools — leverage IAM Access Analyzer, Access Advisor, and CloudTrail.
Monitoring and Auditing
Visibility is critical for maintaining a secure posture:
- IAM Access Analyzer identifies resources shared externally and generates least-privilege policies.
- Access Advisor shows when services were last accessed, helping remove unused permissions.
- AWS CloudTrail logs every API call for forensic analysis and compliance.
Conclusion
IAM is the control plane for security across your entire AWS environment. By mastering principals, policies, and roles—and consistently applying least privilege—you build a strong foundation for a secure cloud architecture. Start with tight permissions, monitor continuously, and refine as your workloads evolve.
Top comments (0)