IAM identities and policy types
Users, groups, roles, the nine policy types, policy JSON elements, condition operators and keys, NotAction, and the IAM size limits the exam quotes.
Exam tasks: 4.2 (Skills 4.2.1 authorization controls and resource policies for cross-account access, 4.2.3 interpret and implement least-privilege policies, 4.2.4 analyze authorization failures)
The decision: which identity, policy type, condition key and operator expresses the restriction the question describes?
IAM is a global service. It authenticates principals and authorizes each request against a set of policies. Everything is denied by default. Permissions come only from an explicit Allow that survives every guardrail.
Identities
| Identity | Credentials | Remember |
|---|---|---|
| Root user | Email and password, optional access keys | Full access. Cannot be limited by IAM policies. Is limited by SCPs and RCPs in member accounts. |
| IAM user | Password for console, up to two access keys | Long-term credentials. Use only where federation or roles are impossible. |
| IAM user group | None | Collection of users for attaching policies. Groups cannot be nested and cannot be a Principal. |
| IAM role | None, issues temporary credentials | Assumed by users, services, other accounts and federated identities. Has a trust policy plus permissions policies. |
Exam signal
"Avoid long-term credentials" or "no embedded keys" points to roles, IAM Identity Center or federation. Long-term access keys are justified only for workloads that cannot use roles, third-party clients that cannot use Identity Center, and break-glass users protected by MFA.
Policy types
AWS lists nine types. Only the first two grant permissions on their own. The rest set limits.
| Type | Attached to | Grants? | Key point |
|---|---|---|---|
| Identity-based | User, group, role | Yes | Managed (AWS or customer) or inline. |
| Resource-based | Resource, such as S3 bucket or role trust policy | Yes, to the named principal | Always inline. Needs a Principal element. |
| Permissions boundary | User or role | No | Caps identity-based grants. Does not cap resource-based grants to a user or role session ARN. |
| SCP | Org root, OU, account | No | Caps principals in member accounts. |
| RCP | Org root, OU, account | No | Caps resources in member accounts, even for outside principals. |
| Session policy | Passed at AssumeRole or GetFederationToken | No | Caps one session. |
| VPC endpoint policy | VPC endpoint | No | Extra boundary for traffic through the endpoint. Default allows all. |
| ACL | Resource (S3, WAF, VPC) | Yes, cross-account only | Only non-JSON type. Cannot grant to the same account. For S3, disable them with Object Ownership. |
| RAM resource share | Shared resource | Yes | Alternative to per-resource policies for sharing subnets, Transit Gateway and similar. |
Inline policies have no ARN of their own and are deleted with the identity. Customer managed policies are reusable and versioned. AWS managed policies cannot be edited.
Policy elements
| Element | Notes |
|---|---|
Version | Use 2012-10-17. Needed for policy variables. |
Sid | Optional label. |
Effect | Allow or Deny. |
Principal | Required in resource-based policies. Not allowed in identity-based policies. |
Action and NotAction | Wildcards allowed, such as ec2:Describe*. |
Resource and NotResource | ARNs. Some actions need *. |
Condition | Optional. Multiple operators in one block are ANDed. Multiple values for one key are ORed. |
Multiple statements and multiple policies are combined with a logical OR before denies are applied.
Condition operators that get tested
| Operator | Behavior |
|---|---|
StringEquals | Exact, case-sensitive. |
StringEqualsIgnoreCase | Exact, ignores case. |
StringLike | Case-sensitive, supports * and ?. |
ArnLike, ArnEquals | Compare each ARN segment. Behave identically. |
IpAddress, NotIpAddress | CIDR match on aws:SourceIp. Absent when a VPC endpoint is used. |
Bool | aws:SecureTransport, aws:MultiFactorAuthPresent. |
Null | "false" means the key must exist. |
...IfExists | Missing key counts as true. Fixes multi-resource actions such as ec2:RunInstances. |
ForAllValues, ForAnyValue | Set operators for multivalued keys. ForAllValues is true on an empty set, so add a Null check. |
A missing key makes a positive operator false. A missing key makes a negated operator such as StringNotLike true.
- Within a condition key, values are OR. Across keys and across operators, it's AND.
- Only the
Likeoperators honour*and?.Booltakes"true"or"false"as strings.
Exam trap
StringLike is not case-insensitive. It is case-sensitive and only adds wildcards. Use StringEqualsIgnoreCase when case must be ignored. Also, aws:SourceIp does not work when a service calls another service on your behalf, because the target sees the calling service address.
Condition keys that decide exam questions
| Key | What it checks | Classic use |
|---|---|---|
aws:PrincipalOrgID | Caller's account is in your organization | Bucket or key policy: allow anyone in the org, no account list |
aws:PrincipalOrgPaths | Caller's OU path | Only accounts under the prod OU |
aws:ResourceOrgID | Resource belongs to your org | Identity or endpoint policy: company buckets only |
aws:SourceVpce / aws:SourceVpc | Request came through this endpoint or VPC | Bucket reachable only from inside the network |
aws:SourceIp | Public IP of the caller | Office egress range. Not populated through VPC endpoints; use aws:VpcSourceIp there |
aws:MultiFactorAuthPresent | Session was created with MFA | Deny sensitive actions without MFA |
aws:MultiFactorAuthAge | Seconds since MFA | Require recent MFA for deletes |
aws:SecureTransport | Request used TLS | Deny HTTP on buckets and queues |
aws:RequestedRegion | Target Region | Region restriction SCPs |
aws:PrincipalTag/..., aws:ResourceTag/..., aws:RequestTag/..., aws:TagKeys | Tags on caller, resource and request | ABAC |
aws:SourceArn / aws:SourceAccount | Which resource made a service call on your behalf | Confused deputy protection in resource policies |
aws:PrincipalIsAWSService, aws:ViaAWSService, aws:CalledVia | The call came from, or through, an AWS service | Exempt service calls from network-perimeter denies |
The MFA deny done right
Long-term access keys never carry aws:MultiFactorAuthPresent. A deny with Bool false misses them, because the
key is absent. BoolIfExists catches both cases:
{
"Sid": "DenyDeletesWithoutMfa",
"Effect": "Deny",
"Action": ["s3:DeleteObject", "s3:DeleteBucket"],
"Resource": "*",
"Condition": { "BoolIfExists": { "aws:MultiFactorAuthPresent": "false" } }
}A network perimeter on a bucket
{
"Sid": "OnlyFromOurEndpointOrServices",
"Effect": "Deny",
"Principal": "*",
"Action": "s3:*",
"Resource": ["arn:aws:s3:::lumen-ledger", "arn:aws:s3:::lumen-ledger/*"],
"Condition": {
"StringNotEqualsIfExists": { "aws:SourceVpce": "vpce-0a1b2c3d4e5f60718" },
"BoolIfExists": { "aws:PrincipalIsAWSService": "false" }
}
}Both conditions must be true for the deny to apply: the request didn't come through the endpoint and it isn't an AWS service principal (such as CloudTrail delivering logs).
aws:SourceIp behind an endpoint
A bucket policy that allows only aws:SourceIp 203.0.113.0/24 breaks as soon as instances reach S3 through a
gateway endpoint, because requests then carry private addresses and no public source IP. Use aws:SourceVpce or
aws:SourceVpc for traffic from your VPCs.
NotAction, NotResource and NotPrincipal
Allow+NotActiongrants every action except those listed, including services launched next year. It's almost never least privilege.Deny+NotActionwith a condition is the useful form: "deny everything except IAM and STS unless MFA is present", or "deny everything outside eu-west-1 except global services".NotResourcein an allow means "every resource except these". Same risk as above.NotPrincipalwithDenyis fragile: you must list the role and the assumed-role session ARN and the account, or you lock out the principal you meant to exempt. Prefer"Principal": "*"with anaws:PrincipalArncondition (ArnNotLike), which matches every session of the role.
Exam signal
If an answer uses NotPrincipal and another uses Principal: * with a StringNotEquals or ArnNotLike
condition on aws:PrincipalArn or aws:PrincipalOrgID, pick the condition version.
Limits and defaults
| Item | Value |
|---|---|
| Customer managed policy size | 6,144 characters (whitespace not counted) |
| Inline policy total per entity | User 2,048, group 5,120, role 10,240 characters |
| Role trust policy length | 2,048 default, adjustable to 8,192 |
| Managed policies per role | 20 default, up to 25 |
| Managed policies per user | 10 default, up to 20 |
| Customer managed policies per account | 1,500 default, up to 10,000 |
| Roles per account | 1,000 default, up to 10,000 |
| Groups per account | 300 default, up to 500 |
| Session policy | 2,048 characters combined with ARNs, max 10 managed ARNs, one JSON document |
| Session tags | Up to 50 |
| Role session name | 64 characters |
Scenarios
With a plain Bool operator, a missing key makes the condition false, so the deny doesn't apply to access-key requests. BoolIfExists treats the missing key as a match. Explicit deny is always evaluated before any allow, and Deny with NotAction is a valid and common pattern. MultiFactorAuthAge is also missing on those requests, so it has the same problem.
aws:PrincipalOrgID checks the caller's organization, so new accounts are covered automatically. aws:SourceAccount describes the resource that made a service-to-service call, not the caller, and listing accounts is what the company wants to avoid. aws:ResourceOrgID describes the resource being accessed, which is always the company's key. An endpoint condition restricts the network path, not who is calling.
Related
- Policy evaluation logic
- Permissions boundaries and iam:PassRole
- Organizations SCPs, RCPs and declarative policies
- Access Analyzer, policy simulator and least privilege tools
- STS, roles and cross-account access
Further reading
Domain 4 · Identity and access management
20% of the exam. Proving who is calling, then deciding exactly what that caller may do, for people, workloads and applications.
Federation with SAML, OIDC and IAM Identity Center
Pick between IAM Identity Center, IAM SAML and OIDC providers, custom brokers and Active Directory options, and trace each token flow.