AWS Identity and Access Management (IAM) decides who can do what in an AWS account. Most security incidents in small accounts are not exotic exploits; they come from permissions that were broader than the job required, long-lived keys that nobody rotated, or roles that trusted the wrong party.
This guide explains how IAM identities, roles and policies fit together, how AWS evaluates a request, and how a small team can move toward least privilege without blocking day-to-day work. IAM features change over time, so confirm current behavior in the official documentation before you rely on a specific setting.
Know the identity types before writing policies
An AWS account has several kinds of identity, and each one should be used for a different purpose. Mixing them up is the root of many permission problems.
| Identity | Credential type | Best use |
|---|---|---|
| Root user | Email, password and MFA | Rare account-level tasks only, such as certain billing and account settings |
| IAM Identity Center user | Temporary credentials through a sign-in portal | Everyday human access, especially across several accounts |
| IAM user | Password and optional long-term access keys | Limited cases where federation is not possible; keep the number small |
| IAM role | Temporary credentials issued when the role is assumed | Workloads, automation, cross-account access and federated humans |
The root user has unrestricted access to the account and cannot be limited by IAM policies in a standalone account. Protect it with a strong unique password and MFA, then stop using it for routine work. The AWS account security checklist covers those first steps in more detail.
For people, AWS recommends federation through IAM Identity Center or an external identity provider so that users receive temporary credentials rather than permanent passwords and keys. A small team can still start with Identity Center inside a single account and grow into a multi-account structure later.
Understand the policy types
A policy is a JSON document that allows or denies actions on resources, optionally under conditions. Several policy types can apply to the same request, and they do different jobs.
- Identity-based policies attach to a user, group or role and say what that identity may do.
- Resource-based policies attach to a resource such as an S3 bucket, KMS key or SQS queue and say who may use it. A role’s trust policy is a special resource-based policy that says who may assume the role.
- Permissions boundaries set the maximum permissions an identity-based policy can grant to a user or role. They do not grant anything on their own.
- Service control policies (SCPs) in AWS Organizations set the maximum permissions for accounts in an organization. They also grant nothing by themselves.
- Session policies can further limit a temporary session when a role is assumed programmatically.
AWS managed policies are convenient for exploration, but many are broad because they are written for general use. Customer managed policies let you narrow actions and resources to your own environment and keep version history.
How AWS evaluates a request
Every API call is checked against the policies that apply to it. The logic is easier to reason about when you remember three rules from the IAM policy evaluation documentation:
- Default deny. If nothing allows the request, it is denied.
- Explicit deny wins. A matching Deny statement in any applicable policy overrides any Allow.
- Guardrails cap, they do not grant. SCPs and permissions boundaries must also permit the action, but an allow in a guardrail does not give access without an identity or resource policy that allows it.
Within a single account, an allow in either the identity-based policy or the resource-based policy is usually enough. Cross-account access is stricter: typically both the caller’s identity policy and the resource’s policy, or the role trust relationship, must allow it.

When a request fails unexpectedly, read the error message carefully. Many AWS services now state which policy type caused an explicit or implicit deny, which shortens troubleshooting considerably.
Write a least-privilege policy in stages
Trying to write a perfect policy on day one usually ends in frustration and a fallback to administrator access. A staged approach works better.
1. Describe the job
Write down what the person or workload needs to accomplish: for example, “deploy the web application to one ECS service and read its logs”. Name the services, the resources and the environment. This description becomes the scope of the policy.
2. Start narrow where you can
Limit actions to the service and the specific operations involved, and limit resources with ARNs rather than * wherever the service supports resource-level permissions. A simple example for read access to a single bucket prefix looks like this:
{
"Version": "2012-10-17",
"Statement": [{
"Effect": "Allow",
"Action": ["s3:GetObject"],
"Resource": "arn:aws:s3:::example-reports/finance/*"
}]
}
3. Generate from real activity
IAM Access Analyzer can generate a policy based on CloudTrail activity for a role over a period you choose. The result is a starting point, not a finished policy: review it, replace broad resources with specific ones, and remove actions that were only used during setup.
4. Validate before attaching
Access Analyzer policy validation flags syntax issues, overly permissive statements and security warnings. Treat its findings as part of the review rather than an optional extra.
Use roles, not stored keys, for workloads
Applications running on AWS rarely need long-term access keys. An EC2 instance can use an instance profile, a Lambda function has an execution role, and ECS tasks have task roles. The service retrieves and rotates temporary credentials automatically.
Long-term keys embedded in code, environment files or CI variables are a common leak path. If a workload outside AWS needs access, prefer an option that issues temporary credentials, such as OIDC federation for CI systems or IAM Roles Anywhere for servers that can hold a certificate. When a long-term key is unavoidable, scope it tightly, store it in a secrets manager and rotate it on a schedule.
Give each workload its own role. A shared “app role” used by several services makes it impossible to tell which service needed which permission, and a compromise of one service exposes all of them.
Cross-account and third-party access
A role trust policy controls who can assume a role. For access between your own accounts, trust the specific account or role ARN that needs it rather than an entire organization or the wildcard principal.
When you grant a third-party service access to your account, AWS recommends an external ID condition in the trust policy to help prevent the confused deputy problem. Record every external trust relationship, its purpose and an owner, and remove it when the vendor relationship ends. The AWS Organizations guide explains how account boundaries make this kind of access easier to contain.
Add conditions and guardrails
Conditions narrow when a statement applies. A few are useful in almost every account:
aws:MultiFactorAuthPresentto require MFA for sensitive actions taken with long-term user credentials.aws:RequestedRegionto keep activity inside the Regions you actually use.aws:SourceIporaws:SourceVpcto limit where calls may originate, with care for services that call on your behalf.- Tag-based conditions such as
aws:ResourceTagandaws:PrincipalTagfor attribute-based access control.
Permissions boundaries are useful when you let developers create their own roles: the boundary ensures any role they create cannot exceed an agreed maximum. In an organization, SCPs can deny actions such as disabling CloudTrail or leaving the organization across every member account.
Review and remove unused access
Permissions drift. Projects end, people change roles and temporary access becomes permanent. Schedule a review, monthly for small accounts or quarterly at minimum, and use the built-in data:
- Last accessed information shows which services and, for some services, which actions an identity has used recently.
- The credential report lists users, password age, MFA status and access key age and last use.
- Access Analyzer findings identify resources shared outside your account or organization and, where enabled, unused roles, keys and permissions.
Pair the review with your audit logs. The CloudTrail vs CloudWatch guide explains where to find the API history that tells you who used a permission and when.
Common IAM mistakes to avoid
- Using the root user or a single shared administrator for daily work.
- Attaching
AdministratorAccessto an application role “just to get it working” and never narrowing it. - Committing access keys to source control or sharing them in chat.
- Trust policies that allow any principal, or a whole external account, to assume a powerful role.
- Granting
iam:PassRoleon*, which can let an identity hand a more powerful role to a service. - No owner or description on roles, so nobody knows whether they can be deleted.
When you assess an account that you are taking over, whether from a colleague, an agency or one of the AWS account listings you are reviewing, inventory every user, role, key and trust relationship before deploying anything. Remove what you cannot explain.
IAM roles and policies questions
Should I still create IAM users?
Only when federation through IAM Identity Center or another identity provider is not practical. For most human access, temporary credentials from federation are the recommended approach.
What is the difference between a role and a user?
A user has long-term credentials tied to one identity. A role has no permanent credentials; it issues temporary credentials to whoever is allowed to assume it, such as a person, a service or another account.
Does an explicit deny override an allow?
Yes. If any applicable policy contains a matching Deny statement, the request is denied regardless of any Allow statements.
How often should IAM permissions be reviewed?
Review on a regular schedule, such as monthly or quarterly, and whenever a person changes role, a project ends or a vendor relationship stops.
Are AWS managed policies safe to use?
They are maintained by AWS and useful for getting started, but many grant broader access than a specific job needs. Replace them with narrower customer managed policies once usage is understood.
Editorial guide by Mark Biden · Reviewed 19 November 2026. Official sources are linked beside the relevant guidance. OldAccs is independent and is not affiliated with or endorsed by Amazon Web Services. Examples are illustrative; verify the current configuration and requirements of your own environment.

Leave a Reply