Unused IAM Permissions: Right-Size AWS Roles With Last-Accessed Data

AWS already records which services each role uses; here is how to read that evidence and remove the rest without breaking workloads.
Find unused IAM permissions with AWS last accessed data and Access Analyzer, choose an observation window, remove the riskiest access first, and repeat monthly.
November 19, 2026

Most AWS roles are allowed to do far more than they ever do. A deploy role that pushes images and updates one ECS service was granted ec2:*, rds:* and secretsmanager:* during a late-night incident two years ago, and nobody took them back. Those unused IAM permissions cost nothing until someone steals the role's credentials. Then they are the attacker's options.

Least privilege is easy to agree with and hard to practice, because writing a tight policy up front means predicting every call a workload will make. The practical route runs the other way: grant what is needed to ship, observe what the identity actually uses, and remove the rest. AWS records the evidence for that second step. Most teams never read it.

This post covers the two AWS data sources for finding unused IAM permissions, how long to observe before you trust them, what to remove first, and how to turn right-sizing into a recurring review instead of a one-time cleanup project.

Why unused IAM permissions pile up

Permissions drift in one direction. Adding access unblocks someone today. Removing access risks breaking something nobody remembers, so it waits. Over time, roles collect:

  • Incident grants. Broad access added to fix an outage, never narrowed afterward.
  • Copied policies. A new service starts from an older service's role and inherits everything it had.
  • Retired features. The code that called DynamoDB was deleted. The dynamodb:* statement was not.
  • Managed policy shortcuts. Attaching a broad AWS managed policy was faster than writing a scoped one.
  • Abandoned identities. Roles for decommissioned workloads and users for people or vendors who left, still valid and still trusted.

Each of these looks harmless on its own. Together they mean the blast radius of a leaked credential is set by the role's history, not by what the workload needs.

Two AWS sources of unused access data

AWS gives you two complementary views of what an identity has actually used. They answer slightly different questions, and it helps to know which one you are reading.

IAM service last accessed data

For any IAM role, user, group or policy, IAM can report which services the identity's policies allow and when the identity last attempted to use each one. You request a report, then read it:

  • aws iam generate-service-last-accessed-details --arn arn:aws:iam::111122223333:role/deploy-api returns a job ID.
  • aws iam get-service-last-accessed-details --job-id <job-id> returns each allowed service with its last authenticated time and Region, or no time at all if the identity never tried it in the tracking period.

The tracking period is the last 400 days, shorter in Regions where AWS started tracking later. For some services the report can go down to individual actions when you request action-level granularity. For most services it stops at the service level.

IAM Access Analyzer unused access findings

An IAM Access Analyzer unused access analyzer runs continuously over an account or a whole AWS Organization and raises findings of four kinds: an unused role, an unused permission, an unused access key and an unused password. Its owner sets the tracking period, from 1 to 365 days. Unused permission findings can name specific unused actions, not just a service, which makes them more precise for the final trim.

The two sources can disagree. Last accessed data uses whatever window you pick when you read it. An analyzer judges against its own configured period. A service unused for 100 days is unused by a 90-day standard and still in use by a 180-day one. Neither is wrong. Know which window you are reading before you act.

What both sources miss

Last accessed data is evidence, not a verdict. Read it with these limits in mind:

  • The allowed list is an upper bound. AWS evaluates identity policies only. Permissions boundaries, service control policies and resource policies are not applied, so a service can be listed as allowed when another layer already denies it.
  • A denied attempt counts as access. If a workload tries a call and gets AccessDenied, the service shows as recently used.
  • Service-level data hides action-level waste. A role that calls s3:GetObject every minute shows S3 as used, even if it also holds s3:DeleteBucket.
  • Analyzers skip young identities. An analyzer evaluates only roles and users that existed for its whole tracking period, and its owner can exclude accounts and tagged identities. No findings does not mean nothing is unused.

How long an observation window to trust

The window is the most important decision in right-sizing. Too short and you remove access a workload needs once a quarter. Too long and nothing ever qualifies for removal.

Ninety days is a sensible default for most workloads. It covers monthly jobs, most quarterly processes and a normal release cadence. Adjust from there:

  • Go longer for rare but critical paths. Disaster recovery roles, year-end finance jobs, annual key rotation and break-glass identities may go months without a call. Use the full tracking period, or tag them and review them by hand.
  • Go shorter for high-churn workloads. A CI role whose pipeline runs dozens of times a day shows its real footprint within weeks.
  • Do not judge new identities. A role created last month has not had a chance to show its pattern. Wait until it is older than the window.
  • Check the code before trusting the data. If a service is unused for 90 days but referenced in a scheduled task or a feature flag that is off, the data is right about the past and wrong about next month.

What to remove first

You do not need to fix every role at once. Order the work by how much risk each removal takes away and how unlikely it is to break something.

  1. Unused identities. Roles that have not been assumed and users that have not signed in or called anything within the window. Disable first, delete after a grace period. This is the cleanest win: a credential that does not exist cannot be stolen.
  2. Unused access keys and passwords. Long-lived keys nobody uses are pure exposure. Deactivate them, wait, then delete.
  3. Whole services never accessed. A service with no recorded access in the tracking period is the safest permission to drop from an active role. Start with services that can change data or access: IAM, KMS, Secrets Manager, Organizations, EC2, RDS and the data stores.
  4. Services unused for longer than the window. Accessed once, long ago. Confirm with the owning team, then remove.
  5. Unused actions inside used services. The precision pass. Replace s3:* with the actions the role calls, using action-level findings where you have them.

Prioritize by the identity, too. A role that an internet-facing workload assumes, or one that a third party can assume through a trust policy, deserves attention before a role used only by an internal batch job.

A worked example: right-sizing a CI deploy role

Here is a deploy role's policy as it stood after a few years of changes:

{"Version":"2012-10-17","Statement":[{"Effect":"Allow","Action":["ecr:*","ecs:*","ec2:*","rds:*","secretsmanager:*","iam:PassRole","logs:*"],"Resource":"*"}]}

The last accessed report for the role, read with a 90-day window, shows ECR, ECS, CloudWatch Logs and IAM in use. EC2 was last accessed eight months ago. RDS and Secrets Manager show no access in the tracking period. An unused access analyzer with a 90-day period agrees on RDS and Secrets Manager and adds an unused permission finding for ECS, naming every action except service updates and task definition registration.

The team checks the pipeline code. The EC2 call came from a migration script that has since been deleted. Nothing references RDS or Secrets Manager. The right-sized policy:

{"Version":"2012-10-17","Statement":[{"Effect":"Allow","Action":["ecr:GetAuthorizationToken"],"Resource":"*"},{"Effect":"Allow","Action":["ecr:BatchCheckLayerAvailability","ecr:InitiateLayerUpload","ecr:UploadLayerPart","ecr:CompleteLayerUpload","ecr:PutImage"],"Resource":"arn:aws:ecr:us-east-1:111122223333:repository/api"},{"Effect":"Allow","Action":["ecs:RegisterTaskDefinition","ecs:UpdateService","ecs:DescribeServices"],"Resource":"*"},{"Effect":"Allow","Action":"iam:PassRole","Resource":"arn:aws:iam::111122223333:role/api-task"},{"Effect":"Allow","Action":["logs:CreateLogStream","logs:PutLogEvents"],"Resource":"*"}]}

Three things made the change safe. The team removed whole unused services first, as a separate change, and watched one week of deploys before narrowing actions. They scoped iam:PassRole to the one task role, because an unscoped PassRole lets the deploy role hand any role to a new task. And they kept the old policy document in version control, so a rollback was one apply.

If a deploy fails afterward, CloudTrail shows the AccessDenied event with the exact action, and the fix is one line in the policy instead of a return to ecs:*.

Make least privilege a recurring IAM access review

A one-time cleanup decays. New grants arrive every sprint, and the roles you trimmed in March will have drifted by September. The fix is to make right-sizing a routine with a cadence, owners and a record.

  • Pick a cadence that matches your data. Monthly works for most teams. Last accessed data and analyzer findings change slowly, so reviewing more often adds noise, not signal.
  • Route each role to its owner. The platform team should not guess what an application role needs. Tag roles with an owning team and send each team its own list.
  • Track a small set of numbers. Unused services per role, unused identities, and unused long-lived keys. The trend matters more than the absolute count.
  • Record exceptions with a reason and an expiry. The disaster recovery role keeps its broad access, written down, with a date to look again.
  • Fix the source, not the console. If the role is declared in Terraform or CloudFormation, change the template. A console edit gets overwritten on the next apply.
  • Keep the evidence. Access reviews are a common audit requirement. A dated record of what was reviewed, what was removed and what was kept is the evidence your compliance program needs.

Checklist for removing unused IAM permissions

  1. Turn on an IAM Access Analyzer unused access analyzer for your AWS Organization, or for each account, with a tracking period that matches your review window.
  2. Pick a default window, such as 90 days, and list the identities that need a longer one.
  3. Pull last accessed data for every role and user older than the window.
  4. Disable unused roles, users, access keys and passwords. Delete them after a grace period.
  5. Remove whole services with no recorded access, starting with IAM, KMS, Secrets Manager and data stores.
  6. Check the code for each remaining candidate before removing it.
  7. Narrow actions within used services, and scope iam:PassRole to named roles.
  8. Make each change in the infrastructure code that declares the role, and keep the prior policy version for rollback.
  9. Repeat on a fixed cadence, with owners, exceptions and a record.

How Heeler shows unused AWS service permissions

Heeler reads this data for you and puts it next to the rest of the cloud context for each identity. The resource drawer for an IAM role or IAM user has an Unused Services section: the AWS services the identity policies allow that the role or user has not accessed in the last 90 days. Heeler reads it from IAM service last accessed information once a week. Each row shows the service, its IAM namespace, when it was last accessed or "Not accessed in the tracking period", and the Region. Services with no recorded access come first.

The section is explicit about the limits above. It says when a role is too new to judge, when it is a service-linked role whose policies AWS manages, and when no report is stored yet, so an empty list is never mistaken for a clean one. Only No unused services means the identity used everything it is allowed.

Where an active IAM Access Analyzer unused access analyzer covers the account, the section adds an Access Analyzer tab with the analyzer's active findings: unused roles, permissions, access keys and passwords, with the unused actions on each permission finding. A line above the table names each analyzer and its tracking period. The two tabs are never merged, so you can see where a 90-day view and the analyzer's own period disagree.

In the Infrastructure catalog, IAM roles and users carry an Unused Services (90 Days) property with the count. The cloud inventory tools on the Heeler MCP server return the same unused services and Access Analyzer data for a role or user, so an AI assistant working through MCP reads the same evidence you see in the drawer. Reading the data needs two IAM actions on the Heeler role, plus three Access Analyzer actions for the findings, all in the latest Heeler IAM template. For the wider practice of running security work across many teams and accounts, see AppSec at scale.

FAQ

What are unused IAM permissions?

Unused IAM permissions are actions or services an identity's policies allow that the identity has not used within an observation window. They add risk without adding function, because a stolen credential can use them even though the workload never does.

How long should I wait before removing an unused permission?

Ninety days is a sensible default for most workloads. Use a longer window, or a manual review, for disaster recovery, break-glass and annual-process roles that may go months between uses.

What is the difference between last accessed data and Access Analyzer unused access findings?

Last accessed data is a report you request per identity, showing each allowed service and when it was last used. An unused access analyzer runs continuously over an account or organization against its own tracking period and raises findings for unused roles, permissions, access keys and passwords.

Does last accessed data account for service control policies?

No. AWS evaluates identity policies only, so permissions boundaries, service control policies and resource policies are not applied, and the allowed list is an upper bound.

Can I safely remove a service that shows no recorded access?

Usually, yes, after checking the code. A service with no recorded access in the tracking period is the lowest-risk removal, but confirm that no scheduled job, disabled feature or recovery path still calls it.

Heeler shows the services each IAM role and user is allowed but never uses, next to the Access Analyzer findings for the same identity, so least privilege becomes a weekly list instead of a quarterly project. Get a demo

What’s new on Heeler
Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.

Related resources

See All Resources