UprootSecurityUprootSecurity

Phase 2 · AWS IAM · Lesson 4 of 4

AWS IAM Policy Syntax Cheat Sheet

Reference

·

10 min

·

+10 pts

Keep this bookmarked

This is a reference you will come back to whenever you write, review, or audit IAM policies. It is designed for scanning, not reading end to end. Use it as a lookup when you need the exact syntax, the correct ARN format, or the right condition key for a policy you are writing.

Policy structure

Every IAM policy follows this skeleton. The annotated version below shows every field you will encounter:

{
  "Version": "2012-10-17",
  "Id": "OptionalPolicyId",
  "Statement": [
    {
      "Sid": "HumanReadableStatementId",
      "Effect": "Allow",
      "Principal": {
        "AWS": "arn:aws:iam::123456789012:role/ExampleRole"
      },
      "Action": [
        "s3:GetObject",
        "s3:ListBucket"
      ],
      "Resource": [
        "arn:aws:s3:::my-bucket",
        "arn:aws:s3:::my-bucket/*"
      ],
      "Condition": {
        "StringEquals": {
          "aws:PrincipalOrgID": "o-exampleorgid"
        }
      }
    }
  ]
}

Field reference

FieldRequiredNotes
VersionYesAlways "2012-10-17". This is the policy language version, not a date you choose.
IdNoOptional identifier for the policy. Used mainly in resource-based policies.
StatementYesArray of one or more permission blocks. Each is evaluated independently.
SidNoStatement ID. Human-readable label. Use it — it makes policies auditable.
EffectYes"Allow" or "Deny". Only two options.
PrincipalConditionalRequired in resource-based and trust policies. Not used in identity-based policies.
ActionYesOne or more API actions in service:ActionName format. Supports wildcards (s3:Get*, s3:*).
NotActionNoInverse of Action — matches everything except the listed actions. Use carefully.
ResourceYesOne or more ARNs the statement applies to. "*" means all resources.
NotResourceNoInverse of Resource — matches everything except the listed ARNs. Rarely needed.
ConditionNoAdditional constraints. See condition operators and keys below.

ARN format

Every AWS resource has an Amazon Resource Name. The format is:

arn:aws:service:region:account-id:resource-type/resource-id

ARN examples by service

ResourceARN
S3 bucketarn:aws:s3:::my-bucket
S3 objects in bucketarn:aws:s3:::my-bucket/*
IAM userarn:aws:iam::123456789012:user/alice
IAM rolearn:aws:iam::123456789012:role/MyRole
DynamoDB tablearn:aws:dynamodb:us-east-1:123456789012:table/MyTable
Lambda functionarn:aws:lambda:us-east-1:123456789012:function:MyFunction
KMS keyarn:aws:kms:us-east-1:123456789012:key/key-id
CloudWatch log grouparn:aws:logs:us-east-1:123456789012:log-group:/aws/lambda/my-function:*
SQS queuearn:aws:sqs:us-east-1:123456789012:my-queue
SNS topicarn:aws:sns:us-east-1:123456789012:my-topic

Note: S3 and IAM ARNs omit the region and account fields (they are global). Most other services require both.

Common actions by service

ServiceCommon ActionsWhen GRC Engineers Care
S3GetObject, PutObject, DeleteObject, ListBucket, GetBucketPolicy, PutBucketPolicyData access controls, encryption enforcement, public access prevention
IAMCreateUser, CreateRole, AttachRolePolicy, AttachUserPolicy, CreateAccessKey, PutRolePermissionsBoundaryPrivilege escalation paths, credential management, delegation controls
CloudTrailStopLogging, DeleteTrail, CreateTrail, PutEventSelectors, GetTrailStatusAudit log integrity — deny StopLogging and DeleteTrail in SCPs
STSAssumeRole, AssumeRoleWithSAML, AssumeRoleWithWebIdentity, GetSessionTokenCross-account access, federation, temporary credential issuance
KMSEncrypt, Decrypt, GenerateDataKey, CreateKey, ScheduleKeyDeletion, CreateGrantData protection, encryption key lifecycle, key access control
OrganizationsCreatePolicy, AttachPolicy, LeaveOrganization, DeleteOrganizationSCP management, organizational structure changes
ConfigStopConfigurationRecorder, DeleteConfigRule, PutConfigRuleConfiguration compliance monitoring — deny StopConfigurationRecorder
GuardDutyDeleteDetector, DisableOrganizationAdminAccount, UpdateDetectorThreat detection — deny DeleteDetector and disable actions

Condition operators

Conditions add constraints beyond Action and Resource. The syntax is:

"Condition": {
  "Operator": {
    "ConditionKey": "Value"
  }
}

Operator reference

OperatorTypeUse Case
StringEqualsExact matchTag values, organization ID, requested region
StringNotEqualsNegated matchExclude specific values
StringLikeWildcard matchPattern matching with * and ?
NumericEqualsNumber matchPort numbers, counts
NumericLessThanNumber comparisonMaximum values
DateGreaterThanDate comparisonTime-based access windows
DateLessThanDate comparisonExpiration dates
BoolBooleanMFA present, secure transport
IpAddressCIDR matchSource IP restrictions
NotIpAddressNegated CIDRExclude IP ranges
ArnLikeARN patternPrincipal ARN matching with wildcards
ArnEqualsExact ARNPrincipal ARN exact matching
NullKey existenceCheck if a condition key is present or absent

Common condition keys

Condition KeyDescriptionExample Use
aws:SourceIpRequester's IP addressRestrict API calls to corporate IP range
aws:PrincipalOrgIDOrganization ID of the requesterEnsure access only from your organization
aws:MultiFactorAuthPresentWhether MFA was usedRequire MFA for sensitive actions
aws:MultiFactorAuthAgeSeconds since MFA authenticationRequire recent MFA for critical operations
aws:RequestedRegionRegion the action targetsRestrict to approved regions only
aws:PrincipalTag/keyTag on the requesting principalAttribute-based access control (ABAC)
aws:ResourceTag/keyTag on the target resourceRestrict actions based on resource tags
s3:x-amz-server-side-encryptionEncryption headerDeny unencrypted uploads
aws:SecureTransportWhether HTTPS was usedDeny non-TLS requests
aws:PrincipalArnARN of the requesting principalRestrict to specific roles or users
aws:CalledViaService that made the callDetect service chaining
kms:ViaServiceService using the KMS keyRestrict which services can use a key

Principal types

Principals identify who is allowed or denied access. Used in resource-based and trust policies.

"Principal": { "AWS": "arn:aws:iam::123456789012:root" }

"Principal": { "AWS": "arn:aws:iam::123456789012:role/MyRole" }

"Principal": { "AWS": "arn:aws:iam::123456789012:user/alice" }

"Principal": { "AWS": "123456789012" }

"Principal": { "Service": "lambda.amazonaws.com" }

"Principal": { "Federated": "cognito-identity.amazonaws.com" }

"Principal": "*"
PrincipalMeaning
Account rootAny principal in that account
Role ARNOnly that specific role
User ARNOnly that specific user
Account IDSame as account root — any principal in the account
ServiceAn AWS service (Lambda, EC2, etc.)
FederatedAn identity provider (Cognito, SAML, OIDC)
"*"Anyone — public access. Use with extreme caution.

Policy type quick reference

Policy TypeAttaches ToGrants Access?Can Deny?Cross-Account?
Identity-based (managed)Users, groups, rolesYesYesNo (source side only)
Identity-based (inline)Users, groups, rolesYesYesNo (source side only)
Resource-basedS3 buckets, KMS keys, SQS, SNS, etc.YesYesYes (can grant cross-account)
Trust policyIAM rolesDefines who can assumeNoYes (specifies cross-account principals)
SCPOUs, accountsNo (restricts only)YesN/A (organization-level)
Permission boundaryUsers, rolesNo (restricts only)No (limits allow)No
Session policyAssumed role sessionsNo (restricts only)No (limits allow)No

Quick patterns

Deny all except specific region

{
  "Effect": "Deny",
  "Action": "*",
  "Resource": "*",
  "Condition": {
    "StringNotEquals": {
      "aws:RequestedRegion": ["us-east-1", "us-west-2"]
    }
  }
}

Require encryption on S3 uploads

{
  "Effect": "Deny",
  "Action": "s3:PutObject",
  "Resource": "arn:aws:s3:::my-bucket/*",
  "Condition": {
    "StringNotEquals": {
      "s3:x-amz-server-side-encryption": "aws:kms"
    }
  }
}

Restrict to corporate IP range

{
  "Effect": "Deny",
  "Action": "*",
  "Resource": "*",
  "Condition": {
    "NotIpAddress": {
      "aws:SourceIp": "203.0.113.0/24"
    }
  }
}

Require MFA for all actions

{
  "Effect": "Deny",
  "Action": "*",
  "Resource": "*",
  "Condition": {
    "BoolIfExists": {
      "aws:MultiFactorAuthPresent": "false"
    }
  }
}

Allow access only from your organization

{
  "Effect": "Allow",
  "Action": "s3:GetObject",
  "Resource": "arn:aws:s3:::shared-bucket/*",
  "Condition": {
    "StringEquals": {
      "aws:PrincipalOrgID": "o-exampleorgid"
    }
  }
}
AWS IAM Policy Syntax Cheat Sheet — UprootSecurity Bootcamp