Sub topic 10
Using policy recommendations to right-size permissions
An unused permission finding tells you that a role or user holds permissions it has not used. A policy recommendation goes one step further and proposes the policy change that removes them. This chapter covers how to retrieve a recommendation, how to read it, and how to apply it without breaking a workload.
This chapter assumes you can read IAM identity-based policies and use the AWS CLI. It also assumes you already have an unused access analyzer with active findings, as covered in the chapters on creating analyzers and reading unused access findings.
What a recommendation is
Access Analyzer's unused access analyzer compares the permissions granted to each IAM role and user with the access activity it has observed during the tracking period. The default period is 90 days, and you set it when you create the analyzer. If a service or action was not used in that window, Access Analyzer reports an UnusedPermission finding.
A recommendation is generated from that finding. It names the existing policy that grants the unused permissions and proposes one of two actions:
CREATE_POLICY: replace or edit an inline or customer managed policy. The recommendation includes a proposed policy document with the unused permissions removed.DETACH_POLICY: detach a policy, typically an AWS managed policy, that grants only unused permissions.
Other finding types have simpler remediation, so they do not need a generated policy. For UnusedIAMRole, UnusedIAMUserAccessKey and UnusedIAMUserPassword findings, the fix is to delete the role, or to deactivate and delete the key or password, after you confirm that nobody needs it.
| Finding type | Typical remediation | Recommended policy generated? |
|---|---|---|
| `UnusedIAMRole` | Review, then delete the role | No |
| `UnusedIAMUserAccessKey` | Deactivate, then delete the key | No |
| `UnusedIAMUserPassword` | Remove the console password | No |
| `UnusedPermission` | Remove or detach the unused permissions | Yes |
Retrieving a recommendation
First list the active unused permission findings and note the id of the one you want to fix. Then call get-finding-recommendation with that ID.
aws accessanalyzer list-findings-v2 \
--analyzer-arn arn:aws:access-analyzer:us-east-1:111122223333:analyzer/account-unused \
--filter '{"status":{"eq":["ACTIVE"]},"findingType":{"eq":["UnusedPermission"]}}' \
--query 'findings[].[id,resource]' \
--output table
aws accessanalyzer get-finding-recommendation \
--analyzer-arn arn:aws:access-analyzer:us-east-1:111122223333:analyzer/account-unused \
--id FINDING_IDThe recommendation is computed on request, so the first call can return a status of IN_PROGRESS. Repeat the call until the status is SUCCEEDED. A FAILED status includes an error code and message.
A successful response has this general shape. The values are illustrative.
{
"resourceArn": "arn:aws:iam::111122223333:role/report-builder",
"recommendationType": "UnusedPermissionRecommendation",
"recommendedSteps": [
{
"unusedPermissionsRecommendedStep": {
"policyUpdatedAt": "2026-11-20T09:14:00+00:00",
"recommendedAction": "CREATE_POLICY",
"existingPolicyId": "report-builder-inline",
"recommendedPolicy": "{\"Version\":\"2012-10-17\",\"Statement\":[...]}"
}
}
],
"status": "SUCCEEDED"
}Three fields matter most:
existingPolicyIdidentifies the policy to change.recommendedActiontells you whether to edit that policy or detach it.policyUpdatedAtis the time the policy was last modified when the analysis ran. If the policy changed after that time, the recommendation may be stale. Request it again.
The recommendedPolicy value is a JSON document stored as a string. To save it to a file, extract it with --query and --output text.
aws accessanalyzer get-finding-recommendation \
--analyzer-arn arn:aws:access-analyzer:us-east-1:111122223333:analyzer/account-unused \
--id FINDING_ID \
--query 'recommendedSteps[0].unusedPermissionsRecommendedStep.recommendedPolicy' \
--output text > recommended.jsonReading the recommended policy
Do not treat the recommended policy as a change that is safe to apply automatically. Compare it with the existing policy and look for these points.
- Removed actions. Confirm that each removed service or action is really not needed. The analysis can only see activity inside the tracking period.
- Retained actions. The recommended policy keeps what the identity used. Check that it does not retain more than you expect, such as a wildcard resource on an action that is used.
- Conditions and resources. Check that the conditions and resource scoping you rely on survived the rewrite.
- Scope of the change. One role can receive permissions from several policies. A recommendation covers a single policy at a time, so you may need to process several findings for one role.
Access Analyzer can see only actions that AWS records in access activity. Activity that does not appear in the data cannot count as evidence of use, and a permission that is used less often than the tracking period will look unused. Examples include a quarterly reporting job, an annual compliance export, and a disaster recovery runbook. Removing those permissions causes an outage on the day the job next runs.
A safe remediation workflow
The same approach works for a single role or for hundreds of them.
Applying the change to a customer managed policy
Versioning gives you a cheap rollback. Create the recommended policy as a new version and make it the default.
aws iam create-policy-version \
--policy-arn arn:aws:iam::111122223333:policy/report-builder-access \
--policy-document file://recommended.json \
--set-as-defaultIf a needed action is denied after the change, switch the default back to the earlier version.
aws iam set-default-policy-version \
--policy-arn arn:aws:iam::111122223333:policy/report-builder-access \
--version-id v1An IAM managed policy can hold at most five versions. Delete old versions that you no longer need before you create a new one, but keep the version you might roll back to.
Inline policies and AWS managed policies
Inline policies have no versions. Save the current document before you overwrite it with aws iam put-role-policy, so you can restore it.
You cannot edit an AWS managed policy. When the recommended action is to detach one, create a customer managed policy from the recommended document, attach it to the role, and then detach the AWS managed policy. Attach first and detach second so the role is never left without permissions during the change.
Verifying the result
After the change, watch CloudTrail for AccessDenied and UnauthorizedOperation errors from the affected principal. Access Analyzer scans on a recurring basis, so the finding does not resolve immediately. When the unused permissions no longer appear in the policy, the finding moves to RESOLVED on a later scan. You do not have to archive it. If you keep a permission on purpose, archive the finding so it stays out of your active queue.
Common mistakes
- Applying a stale recommendation. If someone edited the policy after
policyUpdatedAt, the proposal may drop their new statements, or may keep permissions they removed. Request a fresh recommendation before you apply it. - Fixing the policy but not the other sources. A role can receive the same unused permissions from several attached policies. The finding resolves only when none of them grants the unused access.
- Ignoring newly created identities. A role created last week has little history. Wait for a full tracking period before you act on permission findings for it.
- Changing permissions without an owner. The workload owner knows about seasonal jobs and break-glass use. Include them in the review.
- Expecting recommendations for everything. Role, key and password findings have no recommended policy. Their remediation is to delete or deactivate.
Putting it together
A recommendation is the shortest path from "this role has unused permissions" to a concrete policy change. Retrieve it by finding ID, check that it is current, review it with the workload owner, apply it as a new version, and watch for denied requests. Keep the old version until the tracking period has passed without incident.
Exercise
A recommendation for a customer managed policy returns recommendedAction of CREATE_POLICY. The policyUpdatedAt time is two days before a teammate added a new statement to that policy. What should you do before applying the recommended policy, and why?
Show answer
Request the recommendation again, and apply it only after the status is SUCCEEDED and the policy matches what the analysis saw. The recommended document was built from the older policy, so applying it would remove the teammate's new statement.
Exercise
A role's finding recommends removing s3:PutObject because it has not been used in 90 days. The role belongs to a job that exports data once a year. Name two reasonable responses.
Show answer
Increase the analyzer's unusedAccessAge so the yearly run falls inside the tracking period, or archive the finding after confirming with the owner that the job still exists. Applying the recommendation without checking would break the next yearly export.
Exercise
The recommended action for a finding is to detach an AWS managed policy, but the role still needs some of its permissions. How do you proceed, and in what order?
Show answer
Create a customer managed policy that contains only the needed permissions, attach it to the role, and then detach the AWS managed policy. Attaching first means the role never loses access during the change.