Sub topic 6
Reading unused access findings
This chapter assumes you can read IAM policy JSON and run the AWS CLI. It also assumes you have already created an unused access analyzer, as shown in the earlier chapter on creating analyzers. Here you learn to read what the analyzer reports.
What an unused access analyzer looks at
An unused access analyzer reviews IAM roles and users in your account, or across your organization. It compares what each identity is allowed to do with what it has actually done during the tracking period. The default period is 90 days. The analyzer scans on a recurring schedule, so a new finding can take up to a day to appear.
Service-linked roles are not reported. AWS manages their permissions, so you cannot trim them.
The four finding types
Each finding has a findingType that tells you which kind of unused access it describes.
| Finding type | Resource | Meaning |
|---|---|---|
| `UnusedIAMRole` | Role | Nobody assumed the role during the tracking period. |
| `UnusedIAMUserAccessKey` | User | An active access key was not used to sign a request. |
| `UnusedIAMUserPassword` | User | A console password was not used to sign in. |
| `UnusedPermission` | Role or user | A policy allows services or actions that the identity never called. |
The first three findings point at a whole credential or identity that you may be able to delete or deactivate. UnusedPermission is more granular. It leaves the identity in place and shows which parts of its policies are surplus.
Listing findings
List the active findings of one analyzer. Use list-findings-v2, because the older list-findings call does not return unused access findings.
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 tableA row such as UnusedIAMRole, arn:aws:iam::111122223333:role/reporting-batch, ACTIVE tells you which role to investigate. The full response also contains resourceType, resourceOwnerAccount, createdAt and analyzedAt. The analyzedAt timestamp shows when the analyzer last checked the resource.
Getting the details of one finding
The list call gives you a summary. To see why the finding exists, fetch it by ID.
aws accessanalyzer get-finding-v2 \
--analyzer-arn arn:aws:access-analyzer:us-east-1:111122223333:analyzer/account-unused \
--id FINDING_IDThe findingDetails section depends on the type:
- For a role, it includes the last time the role was used, if it ever was.
- For an access key or password, it includes the last use time of that credential.
- For
UnusedPermission, it lists the unused services and the unused actions, grouped by the policy that grants them.
An identity that has never been used is reported differently from one last used 200 days ago. In the first case there is no last-used date, so check when the identity was created before you trust the result.
Reading a finding in practice
Work through each finding in this order:
- Read
findingTypeto learn whether the whole identity or only some permissions are unused. - Read
resourceto find the owner, using tags, the account and the naming convention. - Read the last-used information and compare it with your tracking period.
- Decide whether the access is truly idle, or whether its use is simply infrequent.
Exercise
A finding has type UnusedPermission for the role app-deploy. Does the finding mean the role itself can be deleted? What should you check first?
Show answer
No. UnusedPermission means the role is in use but some of its allowed services or actions were never called. Deleting the role would break the workload. Read the finding details to see the unused services and actions, then confirm with the owner that no infrequent job needs them.