Skip to Content
Asterrr's Handbook
4 · Identity and access management

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.

InputsOutputsfrom activityResourcepoliciesRoles and usersCloudTraileventsExternal andinternalfindingsUnused accessfindingsGenerated policyIAM AccessAnalyzer
Access Analyzer reads resource policies and IAM activity, then reports external, internal and unused access, and drafts least-privilege policies.

Which tool

too muchshared outside theaccount or orgwho inside the org canreach this criticalresourceroles, keys, permissionsnobody usesstop bad policiesreaching productiontoo littlereal AccessDeniedtesting a policy changeAccess questionToo much or too little?What kind?Access Analyzerexternal accessAccess Analyzerinternal accessAccess Analyzer unusedaccess + last accesseddataPolicy validation + custompolicy checks in CIReal failure or a draft?Read the error message,then CloudTrail errorCodeIAM policysimulatorPolicygeneration fromCloudTrail
Decision tree for which tool
QuestionTool
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 policyPolicy 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

CapabilityWhat it tells youScopeCost
External access analyzerResources shared with principals outside your zone of trust (account or organization), including publicPer RegionFree
Internal access analyzerWhich principals inside the org or account can reach resources you selectSelected resourcesPaid, per resource monitored
Unused access analyzerUnused roles, access keys and passwords, and unused services and actions on used rolesAccount or org, not per RegionPaid, per role or user analyzed
Policy validationGrammar errors, security warnings, suggestions as you write a policyAny policyFree
Custom policy checksCheckNoNewAccess (does this change widen access?), CheckAccessNotGranted (does it allow these critical actions or resources?), CheckNoPublicAccessAny policy, in CIPaid, per check
Policy generationA draft policy built from the actions a role actually used in CloudTrailOne role or userFree
  • 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

ItemValue
Look-back windowUp to 90 days of CloudTrail events
NeedsA CloudTrail trail and a service role for Access Analyzer to read it
Retention in consoleGenerated policy visible 7 days, one at a time
Action-level detailOnly for supported services. Others give service-level detail from last accessed data
Not includedS3 data events and iam:PassRole, which CloudTrail does not log as such
Control Tower trailsNot supported
Cross-account log bucketNeeds a role, bucket policy, and bucket owner object ownership
Large outputSplit 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:PassRole aren'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:SourceIp or aws:MultiFactorAuthPresent. It fills principal and organization keys such as aws:PrincipalOrgID itself.
  • 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 SimulatePrincipalPolicy and SimulateCustomPolicy.
DoesDoes not
Show which statement allows or deniesMake the real API call or return a service response
Evaluate SCP condition keys and resource scopingSupport resource control policies (RCPs)
Accept context key values (IP, MFA, date) you provideMatch live behavior for VPC endpoint policies or role chaining
Fill principal and org keys such as aws:PrincipalOrgIDShow matched SCP statements, only the decision
Leave your account unchangedFetch 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
PhraseMeansLook at
"with an explicit deny in a service control policy"An SCP Deny matchedSCPs on the caller's account path
"with an explicit deny in a resource control policy"An RCP Deny matchedRCPs on the resource's account path
"because no identity-based policy allows"No allow on the principalRole 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 ceilingThe entity's boundary
"because no session policy allows"The session was narrowed at creationWhoever called STS
"because no VPC endpoint policy allows"Traffic went through a restrictive endpointEndpoint policy
"...no role trust policy allows the sts:AssumeRole action"The trust policy doesn't include the callerRole 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 errorCode AccessDenied or UnauthorizedOperation and the userIdentity ARN to see every failed call. EC2 returns an encoded authorization message: decode it with sts:DecodeAuthorizationMessage.
  • For sign-in problems, CloudTrail logs ConsoleLogin, Identity Center sign-in events, and AssumeRoleWithSAML failures (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

Scenario
A fintech company has 120 accounts. The security team must produce a list of every S3 bucket, KMS key and IAM role that grants access to principals outside the company, and be notified whenever a new one appears. What should they do?
Scenario
A platform team wants to stop any pull request that would let an IAM policy allow iam:CreateAccessKey or s3:DeleteBucket from being merged. What is the most direct control?
Scenario
A developer's role has s3:* on the bucket orchard-reports, but GetObject calls fail with 'is not authorized to perform: s3:GetObject ... because no VPC endpoint policy allows the s3:GetObject action'. The instance reaches S3 through a gateway endpoint. What should the security engineer change?

Further reading

On this page