What is IAM Policy?
Parts, Types, Examples and Best Practices

An IAM policy is a set of written rules that says who can do which actions on which cloud resources, and when. In AWS, it is a short JSON document attached to a user, group, role or resource. AWS checks these rules every time someone asks to do something, and says yes or no.

Short Answer An IAM policy, a part of identity and access management (IAM), is a set of written rules that says who can do which actions on which cloud resources, and when. In AWS, each policy is a short JSON document that you attach to a user, group, role or resource. For example, one policy can let the sales team read reports in one storage bucket and nothing else.

What is an IAM Policy?

Identity and access management is the part of IT security that decides who can sign in and what they can touch. Signing in proves who you are, but policies decide what you may do next.

An IAM policy works like the access list at an office reception desk. The list says that Priya from accounts may enter the second floor, but not the server room. In the same way, a policy says that one user may read files in one storage area, but may not delete them. AWS checks these rules every time someone asks to do something, whether they use the AWS Management Console or code.

Most AWS policies use JSON, a simple text format made of names and values inside curly brackets. You do not need to be a programmer to read one. The AWS console also has a visual editor that builds a policy from lists of options.

Key Words to Know

  • Principal: the person, app or service that makes a request.
  • Action: the task someone wants to do, such as reading a file.
  • Resource: the cloud item the action touches, such as a storage bucket.
  • Least privilege: giving each person only the permissions their job needs, and no more.

What Are the Parts of an IAM Policy?

Every policy holds one or more statements. Each statement describes one permission. Also, each statement uses a few standard parts, called elements:

  • Version: the version of the policy language. AWS asks you to always use “2012-10-17”, the current one.
  • Effect: either “Allow” or “Deny”.
  • Action: the list of tasks the statement covers.
  • Resource: the cloud items the actions apply to, named by their Amazon Resource Name (ARN), a unique address for each item.
  • Principal: who the rule is for. You only write it in a resource-based policy, such as a bucket policy or a role’s trust policy. A permissions policy attached to a user or role leaves it out, because the principal is that user or role.
  • Condition: optional extra rules, such as “only if the user signed in with a second step”.

A Simple IAM Policy Example

Suppose a company in Pune keeps monthly sales reports in an Amazon S3 bucket named sales-reports. A bucket is a storage folder in the cloud. The sales team needs to see the list of reports and open them. This IAM policy allows exactly that:

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Action": ["s3:ListBucket", "s3:GetObject"],
      "Resource": ["arn:aws:s3:::sales-reports", "arn:aws:s3:::sales-reports/*"]
    }
  ]
}

Here is what each line means, in plain words:

  1. “Version”: tells AWS to read the rules with the current policy language.
  2. “Statement”: opens the list of rules. This policy has just one.
  3. “Effect”: “Allow”: this rule gives access. It does not block it.
  4. “Action”: s3:ListBucket lets the user see which files are in the bucket. Then s3:GetObject lets them open and download a file.
  5. “Resource”: the first address names the bucket itself, so the list action works. The second address ends in “/*”, which means every file inside that bucket.

The policy gives no right to upload, change or delete files, and it covers no other bucket. So if a sales user tries to delete a report, AWS says no.

Adding a Condition

Now suppose the reports hold sensitive numbers. You can add one more element inside the statement, after the Resource line and a comma:

"Condition": {"Bool": {"aws:MultiFactorAuthPresent": "true"}}

This line means the rule works only when the user signed in with multi-factor authentication, for example a code from a phone app. Without that second step, the Allow does not apply.

What Are the Types of IAM Policies?

AWS supports several policy types. Each one sits in a different place and does a different job. Here are the ones most teams meet first:

  • Identity-based policy: attached to a user, a group of users or a role. It says what that identity can do.
  • Resource-based policy: attached to a resource, such as an Amazon S3 bucket policy. It says who can use that resource, including people from other AWS accounts.
  • Trust policy: a resource-based policy on a role. It says who may take on (assume) that role.
  • Permissions boundary: sets the most an identity-based policy can ever give a user or role. It does not give any access by itself.
  • Session policy: limits what a short, temporary sign-in session can do.
  • Organization policies: service control policies (SCPs) and resource control policies (RCPs) set the most any account can allow. They work in AWS Organizations, which links all the AWS accounts one company runs. They also give no access by themselves.

Managed and Inline Policies

Identity-based policies come in two styles. A managed policy stands on its own, so you can attach it to many users, groups and roles. AWS writes and updates some of them (AWS managed policies), and you write others yourself (customer managed policies). In contrast, an inline policy belongs to just one user, group or role. When you delete that identity, its inline policy goes with it. In most cases, AWS recommends managed policies over inline ones, because one change then reaches everyone who uses the policy.

IAM Policy vs IAM Role

An IAM policy is the rule; the most common kind sits on a user, group or role. A role is an identity that carries rules. A role has no password or long-term keys. Instead, a person, app or AWS service takes on the role for a short time and gets temporary credentials, short-lived sign-in keys. The role’s policies then decide what they can do. A bucket policy is a third idea: a policy that sits on the storage bucket, not on the person.

Question Identity-Based Policy IAM Role S3 Bucket Policy
What is it? A set of permission rules An identity that uses policies A rule set on one bucket
Where does it sit? On a user, group or role In your AWS account On the bucket itself
Does it name a principal? No, the principal is the identity it sits on Its trust policy names who can use it Yes, it must
Typical use Give a team the access it needs Give an app or another account short-term access Share one bucket, or block access to it
A user group and a role each carry their own rules, and the storage bucket carries its own bucket policy
Identity-based policies travel with users and roles, while a bucket policy stays on the bucket it protects.
Talk to an ExpertDo your cloud users have more access than they need? Talk to our team about reviewing your IAM policies.

How Does AWS Decide Whether to Allow a Request?

AWS calls this policy evaluation, and it follows three rules. Every answer starts as no. A request needs at least one clear Allow. One clear Deny beats every Allow. For a request inside one AWS account, AWS works through these steps:

  1. Start with no: AWS denies every request by default. AWS calls this an implicit deny. The only exception is the account’s main owner login, the root user, which has full access unless organization policies limit it.
  2. Look for a Deny: AWS reads every policy that applies. If even one statement says Deny for this request, the answer is no, and nothing can change it.
  3. Check the limits: next, in most cases, any upper limits must also allow the action. These are organization policies, permissions boundaries and session policies, if you use them.
  4. Look for an Allow: an identity-based or resource-based policy must allow the action. If AWS finds one, the answer is yes. Otherwise, it stays no.
Flow chart where a request starts as denied, any Deny ends it, and only a clear Allow lets it through
AWS denies by default, an explicit Deny always wins, and a request goes through only when a policy clearly allows it.

An Example From a Bengaluru Software Company

A software company in Bengaluru gives its developers a policy that allows every action in its test account, backups included. Later, the security team adds a second policy that denies deleting any backup. One evening, a developer runs a cleanup script that tries to delete old backups. AWS finds the Allow, but it also finds the Deny. So the Deny wins, and the backups stay safe.

Tools That Help You Write and Test an IAM Policy

A small mistake in a policy can either block real work or open far too much. Therefore, AWS gives you tools to check policies before and after you use them:

  • IAM policy simulator: it tests how AWS would judge a request against your policies, without sending a real request. It shows allowed or denied for each action and points to the statement that decided it. Its results can still differ from the live account in some advanced setups, so AWS suggests checking the real result too.
  • IAM Access Analyzer policy validation: while you write or edit a JSON policy, it runs more than 100 checks. It warns you about errors and about statements that give too much access.
  • IAM Access Analyzer policy generation: it reads your AWS CloudTrail activity logs and builds a draft policy from the actions a user or role really used.
  • Last accessed information: the Last Accessed tab in the IAM console shows when each service, and some actions, were last used, so you can remove the access nobody needs.

How Azure Handles the Same Job

Microsoft Azure gives access through role assignments in Azure role-based access control (Azure RBAC). A role assignment joins three things: who gets access, a role definition (the list of allowed actions) and a scope, such as one resource group, a folder of related Azure items. Our page on role-based access control explains this model in plain words.

Azure Policy is a separate service, despite its name. It checks the settings of resources, for example that new servers only go to approved regions, and it can block resources that break company rules. So Azure RBAC mainly controls what people can do, while Azure Policy mainly controls what resources may look like. That second job is part of cloud governance.

IAM Policy Best Practices

AWS’s own guidance points to a few habits that keep policies tight in any company:

  • Follow least privilege: start with the smallest set of permissions, then add more only when a task needs them.
  • Use roles, not long-term keys: roles hand out temporary credentials. In contrast, access keys stored in code or on laptops can leak and stay valid for a long time.
  • Avoid wide wildcards: a “*” in Action or Resource can mean every action or every resource. Use it only when you truly mean “all”.
  • Review unused access: use last accessed information to remove users, roles and permissions that no one has used for months.
  • Add conditions: for example, require a second sign-in step for sensitive data, or allow requests only over secure connections. Conditions that use tags also support attribute-based access control.
  • Protect powerful accounts: keep administrator rights for a very small group, and lock away the root user. Our page on privileged access management covers this in more detail.

These habits also fit a zero trust approach, where no user or app gets access just because it sits inside the company network. Finally, an IAM policy is only one part of cloud security. Encryption and logging still matter too.

Frequently Asked Questions About IAM Policy

What is the IAM policy simulator?

The IAM policy simulator is an AWS tool that tests your policies without touching anything real. You pick a user, group or role, or paste in a draft policy. Then you choose actions and resources, and it shows allowed or denied for each one. It also points to the statement behind the answer. However, results can differ in some advanced setups, so check the live result too.

What is an IAM policy document?

An IAM policy document is the JSON text that holds the rules. It starts with a Version line, usually “2012-10-17”, and then a list of statements. Each statement says Allow or Deny, lists the actions and names the resources. It can also add conditions. In the AWS console, you can write it by hand or build it with the visual editor.

What is a principal in an AWS policy?

A principal is the person, app or service that makes a request to AWS. It can be an IAM user, a role, a whole AWS account or an AWS service. You write the Principal element only in resource-based policies, such as a bucket policy or a role’s trust policy. Permissions policies attached to a user or role leave it out.

What is an IAM trust policy?

A trust policy is a JSON policy attached to an IAM role. It says who may take on, or assume, that role. For example, it can let the Amazon EC2 service assume a role, so an app on a server reads a bucket without stored keys. Every role needs a trust policy, plus a permissions policy that says what the role can do.

What is the difference between an IAM policy and a bucket policy?

An identity-based IAM policy sits on a user, group or role and says what that identity can do. A bucket policy sits on one Amazon S3 bucket and says who can use that bucket. So a bucket policy must name a principal. Also, a bucket policy can give access to people in other AWS accounts. AWS checks both kinds together, and any Deny wins.

Is there an IAM policy generator in AWS?

Yes. IAM Access Analyzer can generate a draft policy from your AWS CloudTrail activity logs. It looks at the actions a user or role really used over a period you choose. Then it builds a policy that covers only those actions. You review the draft, test it and attach it. This is often quicker than writing least privilege rules from scratch.

What is an IAM session policy?

A session policy is a short JSON policy that you pass when you request temporary credentials, for example when an app assumes a role. It can only narrow access for that one session. The session gets the overlap of the role’s own policies and the session policy. So a session policy never adds access. Teams use it to hand out a smaller slice of a powerful role.
Use CaseSecure Cloud Infrastructure and Workloads

References

  1. Policy types, JSON elements and least privilege: AWS documentation, Policies and permissions
  2. How AWS allows or denies a request: AWS, How AWS enforcement code logic evaluates requests to allow or deny access
  3. Azure Policy compared with Azure RBAC: Microsoft Learn, Overview of Azure Policy
Stay Updated

Get the Latest Terms & Insights.

New encyclopedia terms, threat intelligence, and architecture decisions, by email.

Book a Consultation

A practice principal will contact you within 1 business day.

Thank you! A Signisys principal will be in touch within 1 business day.