Access Analyzer, policy simulator and least privilege tools
IAM Access Analyzer analyzers, policy validation, custom checks and generation, the policy simulator, last accessed data and reading AccessDenied messages.
Exam tasks: 4.2 (Skills 4.2.3 least-privilege policies, 4.2.4 analyze authorization failures with the policy simulator and Access Analyzer, 4.2.5 investigate and correct unintended permissions), 4.1 (Skill 4.1.3 troubleshooting with CloudTrail)
The decision: is the problem too much access (find and remove it) or too little (find the layer that blocks it), and which tool answers that fastest?
IAM Access Analyzer reasons about policies to find who can reach what. The policy simulator answers what would this request do. Last accessed data and policy generation support right-sizing permissions.
Which tool
| Question | Tool |
|---|---|
| Who outside my org can access this? | Access Analyzer external access |
| Why was this request denied? | Policy simulator, DecodeAuthorizationMessage, CloudTrail |
| What can role X really use? | Last accessed, unused access analyzer |
| Write the minimal policy | Policy generation |
| Is the draft policy safe to merge? | Policy validation and custom checks |
| Which keys are old or lack MFA? | Credential report |
IAM Access Analyzer
| Capability | What it tells you | Scope | Cost |
|---|---|---|---|
| External access analyzer | Resources shared with principals outside your zone of trust (account or organization), including public | Per Region | Free |
| Internal access analyzer | Which principals inside the org or account can reach resources you select | Selected resources | Paid, per resource monitored |
| Unused access analyzer | Unused roles, access keys and passwords, and unused services and actions on used roles | Account or org, not per Region | Paid, per role or user analyzed |
| Policy validation | Grammar errors, security warnings, suggestions as you write a policy | Any policy | Free |
| Custom policy checks | CheckNoNewAccess (does this change widen access?), CheckAccessNotGranted (does it allow these critical actions or resources?), CheckNoPublicAccess | Any policy, in CI | Paid, per check |
| Policy generation | A draft policy built from the actions a role actually used in CloudTrail | One role or user | Free |
- Zone of trust: the account or organization you choose when creating the analyzer. Anything inside it is trusted and generates no external finding.
- External access covers S3 buckets and directory buckets, IAM role trust policies, KMS keys, Lambda functions and layers, SQS, SNS, Secrets Manager, EBS and RDS snapshots, ECR, EFS and DynamoDB tables and streams.
- Findings are active, archived (expected, often through archive rules for known partners) or resolved (the access is gone). Rescan after a fix instead of waiting for the periodic scan.
- Create an external access analyzer in every Region you use. Findings flow to Security Hub and EventBridge, covered in security findings hub.
- Preview access before you change a bucket or key policy: Access Analyzer shows the findings the new policy would create.
- External access analyzers are Regional and reanalyze within about 30 minutes of a policy change.
- The internal access analyzer covers S3, RDS snapshots, DynamoDB tables and streams.
- The unused access analyzer skips service-linked roles. Custom policy checks are billed per API request.
Exam signal
"Identify all resources shared with accounts outside the organization" means an external access analyzer with
the organization as the zone of trust, created from the delegated administrator. "Fail the pipeline if a policy
change grants new permissions" means custom policy checks (CheckNoNewAccess) in CI.
Exam signal
"Detect an S3 bucket policy that now allows another account" is an external access analyzer. "Remove permissions nobody used within the tracking period" is unused access. "Block a pull request that widens a role policy" is custom policy checks. "Create a least-privilege policy from what the role actually did" is policy generation.
Access Analyzer as a preventive control
Access Analyzer finds and reports. It doesn't block a bad policy. If the question asks to prevent external sharing, the answer is an RCP, SCP or resource policy condition, with Access Analyzer as the detective partner.
Policy generation limits
| Item | Value |
|---|---|
| Look-back window | Up to 90 days of CloudTrail events |
| Needs | A CloudTrail trail and a service role for Access Analyzer to read it |
| Retention in console | Generated policy visible 7 days, one at a time |
| Action-level detail | Only for supported services. Others give service-level detail from last accessed data |
| Not included | S3 data events and iam:PassRole, which CloudTrail does not log as such |
| Control Tower trails | Not supported |
| Cross-account log bucket | Needs a role, bucket policy, and bucket owner object ownership |
| Large output | Split into several policies if over 6,144 characters |
Exam trap
Policy generation includes denied actions seen in CloudTrail, so review the draft before attaching. It is also not an audit tool. Use CloudTrail for auditing.
Refining permissions
Start broad but bounded. An AWS managed or team policy, under a permissions boundary or SCP.
Observe. Run the workload through a full business cycle (month-end jobs included).
Generate. Use Access Analyzer policy generation over that period's CloudTrail trail, then add resource ARNs and conditions the generator can't know.
Validate and check. Run policy validation and CheckAccessNotGranted for actions that must never appear.
Keep trimming. Review unused access findings and last accessed data, and remove what stays unused.
Last accessed data
- Shows when an identity (or an OU or account, from the management account) last used each service, and for many services the last management action.
- Tracks at least 400 days. New activity can take up to 4 hours to appear.
- Covers only access granted by identity policies (or SCPs, for the Organizations view). Resource policies, data
events and
iam:PassRolearen't tracked. - Use it to shrink SCP allow lists and remove unused services from roles.
- Access Advisor also shows the last used actions for some services (EC2, IAM, Lambda, S3). In the management account, the Organizations section shows it for OUs, accounts and policies.
IAM policy simulator
- Tests identity policies, permissions boundaries, SCPs, and resource policies you provide, without making real calls.
- Principal mode tests an existing user, group or role. Custom mode tests a policy you paste in before attaching it.
- You supply condition values such as
aws:SourceIporaws:MultiFactorAuthPresent. It fills principal and organization keys such asaws:PrincipalOrgIDitself. - It doesn't evaluate RCPs, and results can differ from reality for VPC endpoint policies, role chaining and some cross-account setups. Confirm with a real test.
- The APIs are
SimulatePrincipalPolicyandSimulateCustomPolicy.
| Does | Does not |
|---|---|
| Show which statement allows or denies | Make the real API call or return a service response |
| Evaluate SCP condition keys and resource scoping | Support resource control policies (RCPs) |
| Accept context key values (IP, MFA, date) you provide | Match live behavior for VPC endpoint policies or role chaining |
Fill principal and org keys such as aws:PrincipalOrgID | Show matched SCP statements, only the decision |
| Leave your account unchanged | Fetch resource policies for you outside the console |
Reading an AccessDenied
Most services now say which policy type denied the call and whether it was explicit or implicit:
User: arn:aws:sts::404040404040:assumed-role/ledger-batch/job-7781 is not authorized to perform:
kms:Decrypt on resource: arn:aws:kms:eu-west-1:404040404040:key/9f1e...
with an explicit deny in a resource control policy| Phrase | Means | Look at |
|---|---|---|
| "with an explicit deny in a service control policy" | An SCP Deny matched | SCPs on the caller's account path |
| "with an explicit deny in a resource control policy" | An RCP Deny matched | RCPs on the resource's account path |
| "because no identity-based policy allows" | No allow on the principal | Role or user policies |
| "because no resource-based policy allows" | Resource policy didn't grant it (often cross-account) | Bucket, key or queue policy |
| "because no permissions boundary allows" | Boundary is the ceiling | The entity's boundary |
| "because no session policy allows" | The session was narrowed at creation | Whoever called STS |
| "because no VPC endpoint policy allows" | Traffic went through a restrictive endpoint | Endpoint policy |
| "...no role trust policy allows the sts:AssumeRole action" | The trust policy doesn't include the caller | Role trust policy, external ID, conditions |
- When several policy types deny, the message names only one. Fix it, retry, and check again.
- In CloudTrail, filter on
errorCodeAccessDeniedorUnauthorizedOperationand theuserIdentityARN to see every failed call. EC2 returns an encoded authorization message: decode it withsts:DecodeAuthorizationMessage. - For sign-in problems, CloudTrail logs
ConsoleLogin, Identity Center sign-in events, andAssumeRoleWithSAMLfailures (such as an invalid audience or an expired assertion). See troubleshooting monitoring.
Exam signal
"The error message says explicit deny in a service control policy, but the account admin can't find any deny in the account" means the SCP is attached higher up: an OU or the root. Only the management account or delegated admin can see and change it.
Scenarios
An organization-wide external access analyzer reports resources shared outside the organization, and its findings raise events for new sharing. Unused access analysis looks at roles and keys nobody uses, not external sharing. The simulator tests access for principals you pick, and can't discover who outside has access. Config public bucket rules miss cross-account grants, KMS keys and role trust policies.
CheckAccessNotGranted evaluates a policy document against actions you say must never be granted, and fits a CI gate. Unused access findings arrive after deployment. An SCP blocks the actions everywhere, including for the teams that legitimately need them, and doesn't review the policy. A manual simulator run doesn't block a merge.
The message names the endpoint policy as the layer that implicitly denies, so the endpoint policy needs an allow for that bucket. The bucket policy and boundary aren't what failed, and the error would name them if they were. Block Public Access doesn't affect private access through an endpoint.
Related
- Policy evaluation logic
- IAM identities and policy types
- Organizations SCPs, RCPs and declarative policies
- Credentials, MFA and root access
- AWS Security Hub
Further reading
Organizations SCPs, RCPs and declarative policies
Service control policies, resource control policies, declarative policies and AI opt-out policies. What each guards, what it cannot touch, how they combine and how they build data perimeters.
Identity and access quiz
Ten scenario questions on identity and access management for the SCS-C03 exam.