Anatomy of IAM Policies in AWS

AWS IAM

Example IAM Policy

IAM policy elements and their meaning
IAM policy elements and their meaningVersion This defines the version of the policy language, not the version of the managed policy itself. 2012-10-17 is the latest and should be used to access all features. Statement The policy statement where you add what’s allowed or denied using Effects, Actions, and Resources. Effect Allow: Allows the specified action(s) against the specified resource(s), subject to other applicable policies. Deny: Explicitly denies the specified action(s) against the specified resource(s). Useful to overrule allow statements. Implicit deny: By default, IAM assumes actions aren’t allowed. Without an applicable allow, the request is implicitly denied. This is not an Effect value. Action The action(s) to be allowed or denied. This can be a single action or an array of actions. Resource This is the resource(s) for which the effect and action(s) will be applied. For example, it can be EC2 resources, S3 resources, roles, users, etc. ARN: Amazon Resource Name (unique identifier). Condition Specific conditions for when a policy is in effect. This is optional and it can take in a number of different condition operators, condition keys, and condition values. Condition example This example denies the listed actions when none of the requested tag keys matches Production. It checks tag names, not values, and also applies when no tag keys are provided. Condition operator: ForAllValues:StringNotLike Condition key: aws:TagKeys Condition value: ProductionIAM policy · JSON{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "s3:GetObject", "s3:PutObject", "s3:DeleteObject" ], "Resource": "arn:aws:s3:::example-bucket/*" }, { "Effect": "Allow", "Action": "ec2:StartInstances", "Resource": "arn:aws:ec2:region:account-id:instance/instance-id" }, { "Effect": "Allow", "Action": "ec2:DescribeInstances", "Resource": "*" }, { "Sid": "RunInstancesRestrictions1", "Effect": "Deny", "Action": [ "ec2:CreateVolume", "ec2:RunInstances" ], "Resource": [ "arn:aws:ec2:*:*:volume/*", "arn:aws:ec2:*:*:instance/*" ], "Condition": { "ForAllValues:StringNotLike": { "aws:TagKeys": "Production" } } } ]}VersionThis defines the versionof the policy language,not the version of themanaged policy itself.2012-10-17 is the latestand should be used toaccess all features.StatementThe policy statement whereyou add what’s allowed ordenied using Effects,Actions, and Resources.EffectAllowAllows the specifiedaction(s) against thespecified resource(s),subject to otherapplicable policies.DenyExplicitly denies thespecified action(s)against the specifiedresource(s). Useful tooverrule allow statements.Implicit denyBy default, IAM assumesactions aren’t allowed.Without an applicableallow, the request isimplicitly denied. This isnot an Effect value.ActionThe action(s) to beallowed or denied. Thiscan be a single action oran array of actions.ResourceThis is the resource(s)for which the effect andaction(s) will be applied.For example, it can be EC2resources, S3 resources,roles, users, etc.ARNAmazon Resource Name(unique identifier).ConditionSpecific conditions forwhen a policy is ineffect. This is optionaland it can take in anumber of differentcondition operators,condition keys, andcondition values.Condition exampleThis example denies the listed actions when none of therequested tag keys matches Production. It checks tagnames, not values, and also applies when no tag keys areprovided.Condition operatorForAllValues:StringNotLikeCondition keyaws:TagKeysCondition valueProduction
IAM policy elements and their meaning

Drag the background to pan. Use the controls to zoom or fit the full diagram. Press Escape to close.

Use this cheat sheet with AI

Copy a ready-to-use prompt into your preferred AI assistant.

Preview prompt