Sub topic 6
Reading unused access findings
This chapter assumes you know IAM users, roles and identity-based policies, and can read a JSON policy. It also assumes you can run AWS CLI commands and that you have created an analyzer of type ACCOUNT_UNUSED_ACCESS or ORGANIZATION_UNUSED_ACCESS. The previous chapter covered findings about access from outside your zone of trust. This chapter covers findings about access that exists inside your account but that nobody exercises.
What an unused access finding tells you
An external access finding says "someone outside can reach this resource." An unused access finding says "this identity, credential or permission has not been used for the tracking period." The tracking period is the number of days you set with unusedAccessAge when you created the analyzer. You can choose a value from 1 to 365, and 90 is a common starting point.
Unused access is a risk even though nobody is exploiting it. A forgotten access key can be stolen and used without anyone noticing. An overly broad role that is never used for most of its permissions gives an attacker more room if the role is compromised. The findings give you a list of what to remove or tighten.
Findings are evidence about past behavior only. The analyzer cannot know about a job that runs once a year, or a role kept for disaster recovery. Reading a finding well means deciding whether "unused" really means "unneeded."
The four finding types
Each finding has a findingType that tells you what kind of access went unused.
| Finding type | Resource it points to | What was unused |
|---|---|---|
| `UnusedIAMRole` | An IAM role | The whole role. Nobody assumed it during the tracking period. |
| `UnusedIAMUserAccessKey` | An IAM user | One active access key of that user. |
| `UnusedIAMUserPassword` | An IAM user | The user's console password. |
| `UnusedPermission` | An IAM role or user | Services or actions allowed by the identity's policies but never called. |
The first three findings concern whole identities or credentials. The fourth works at a finer grain. It covers permissions inside an identity that is otherwise in use, so an active role can still produce several UnusedPermission findings.
The diagram below summarizes how to approach each type.
Listing findings
List the active findings of an unused access analyzer with list-findings-v2. Use this version of the command, not the older list-findings, because list-findings-v2 returns findings of every analyzer type.
aws accessanalyzer list-analyzers --query 'analyzers[].[name,type,arn]' --output table
aws accessanalyzer list-findings-v2 \
--analyzer-arn arn:aws:access-analyzer:us-east-1:111122223333:analyzer/account-unused \
--filter '{"status":{"eq":["ACTIVE"]}}' \
--query 'findings[].[findingType,resource,status]' \
--output tableThe resource column holds the ARN of the role or user. The --filter option narrows the list. To see only unused roles, add a findingType condition:
aws accessanalyzer list-findings-v2 \
--analyzer-arn arn:aws:access-analyzer:us-east-1:111122223333:analyzer/account-unused \
--filter '{"status":{"eq":["ACTIVE"]},"findingType":{"eq":["UnusedIAMRole"]}}' \
--query 'findings[].[id,resource,analyzedAt]' \
--output tableThe list output is a summary. To find out what exactly went unused, fetch one finding by its ID.
Reading a single finding
get-finding-v2 returns the details for one finding. The findingDetails field changes shape with the finding type.
aws accessanalyzer get-finding-v2 \
--analyzer-arn arn:aws:access-analyzer:us-east-1:111122223333:analyzer/account-unused \
--id FINDING_IDFor an UnusedPermission finding, the response contains an abbreviated structure like this:
{
"findingType": "UnusedPermission",
"resource": "arn:aws:iam::111122223333:role/report-builder",
"resourceType": "AWS::IAM::Role",
"status": "ACTIVE",
"findingDetails": [
{
"unusedPermissionDetails": {
"serviceNamespace": "s3",
"actions": [
{ "action": "s3:DeleteObject" },
{ "action": "s3:PutObject" }
]
}
}
]
}The other types carry different details. A role finding includes a lastAccessed timestamp in unusedIamRoleDetails. An access key finding names the accessKeyId in unusedIamUserAccessKeyDetails. A password finding has unusedIamUserPasswordDetails. When lastAccessed is present, compare it to your tracking period. A role last used 95 days ago with a 90-day period is a borderline case worth a quick check. A role with no recorded use at all is a stronger candidate for removal.
For permission findings, read two things. First, the service namespace and the actions. The finding may list whole services that were never called, or specific actions inside a service that the role does use. Second, which policy grants them. A finding about s3:DeleteObject on a role that otherwise reads S3 suggests a policy written with a broad action list, such as s3:*.
Judging whether "unused" means "unneeded"
Before acting on any finding, ask these questions.
- Is the tracking period long enough for this workload? A quarterly report job or an annual audit role will look unused in a 90-day window. If the workload is real, either lengthen the period (the maximum is 365 days) or archive the finding with a rule, which the next chapters cover.
- Could the access be a break-glass path? Emergency roles are meant to sit idle. An unused finding on them is expected. Treat the finding as a prompt to confirm the role still works and is still guarded, not as an instruction to delete it.
- Is the activity visible to the analyzer? Findings depend on recorded last-accessed information. Some actions are not tracked at the action level for every service, so a permission can appear unused when it is used in a way the data does not capture. Check the service's documentation before deleting a permission that an application might need.
- Who owns the identity? Look at tags, the role's trust policy and the CloudTrail history. A role used only by a pipeline in another account still shows activity in yours when that pipeline assumes it.
- What breaks if you are wrong? A deactivated access key is easy to reactivate. A deleted role loses its ARN's history and its trust policy, and recreating it with the same name does not restore references that depend on its unique ID. Pick the reversible action first.
Tracking period trade-offs
The tracking period is a trade-off between noise and coverage.
- A short period, such as 30 days, produces more findings. It catches stale access quickly, but it flags periodic workloads that are still needed.
- A long period, such as 365 days, produces fewer false alarms. It also leaves unused credentials in place for up to a year before you see them.
You set the period at creation with unusedAccessAge, as in --configuration '{"unusedAccess":{"unusedAccessAge":90}}'. One analyzer has one period. If your account has workloads with different rhythms, a single period cannot fit all of them. Pick the period for the common case and handle the exceptions with archive rules.
Common mistakes
- Treating the list as a to-do list to clear. Some findings are correct to leave alone. Decide per finding.
- Deleting a role before checking its last use and owner. Disable it first, for example by attaching a deny-all policy or removing it from the trust policy, wait one cycle of the workload, then delete.
- Ignoring
UnusedPermissionfindings because the role is active. An active role with a wide policy is the case where least-privilege changes matter most, because the role is a live target. - Using
list-findingsinstead oflist-findings-v2. The older call does not return unused access findings. - Assuming a finding disappears instantly after you fix it. The analyzer re-evaluates on its own schedule, so allow time before you conclude a fix did not work.
Exercise
An unused access analyzer is set to a 90-day tracking period. It reports an UnusedIAMRole finding for a role named year-end-audit, which an auditor assumes once a year in December. What are two reasonable ways to respond, and why should you not simply delete the role?
Show answer
The role is needed, but its use is less frequent than the tracking period, so the finding is a false alarm for this workload. You can archive the finding with an archive rule for that role's ARN, or you can use a longer tracking period (up to 365 days) if many roles follow an annual rhythm. Deleting it would remove a role that the audit needs, and recreating a role does not preserve references to its original unique ID.
Exercise
Which command returns the specific unused actions for one UnusedPermission finding, and in which part of the response do they appear?
Show answer
aws accessanalyzer get-finding-v2 --analyzer-arn ARN --id FINDING_ID. The actions appear under findingDetails, in unusedPermissionDetails, together with the service namespace.