That role has permissions nobody uses. Here is the PR.
Works with AWS IAM Terraform GitHub Python
Dawnfix Leastpriv reads an IAM role's last-accessed data (and Access Analyzer's unused-access findings, when you have an analyzer), works out which permissions went unused for 90 days, and writes the change as a reviewable diff: a patch for your policy JSON in the repo, Terraform and CloudFormation renderings, and a PR body with a risk note for every removed action. It never changes IAM. Free and source available.
How it decides
- Removes only with evidence: a service unused in the window loses all its actions; an explicit action IAM tracks at action level and that went unused goes.
- Keeps wildcards in a used service,
Action: "*",NotActionand every Deny; for those it suggests the actions actually used instead. - AWS managed policies cannot be edited: it says to detach one and attach a customer managed document it writes.
- Risk per removal: high for rare-but-critical actions (restore, failover, secret rotation, certificate renewal,
iam:PassRole, deploy and scaling paths, break-glass); medium when the role is younger than the window; low otherwise. - Not covered yet: resource-level narrowing, permission boundaries and SCPs. Only the JSON patch applies to your repo file; the Terraform and CloudFormation diffs are renderings to copy from.
How to run it
- Install the CLI from PyPI. The
dawnfixpackage (version 0.5.0, Python 3.11 or later) holds every Python tool. To build from source instead, clone dawnfix/dawnfix and runmake installin itsleastpriv/folder:python3 -m venv .venv .venv/bin/pip install dawnfix==0.5.0 - Sign in to AWS, open the repo that holds the role's policy, then:
It writes the PR body and the patch. You open the PR yourself, after review..venv/bin/leastpriv role app-worker --days 90 --policy-file app=iam/app.json # -> leastpriv-out/pr.md, report.json, app.patch (git apply), *.diff - Or use it from your coding agent: paste
prompts/leastpriv.md. The agent runs the trim, shows the risk table and the patch, and opens the PR only when you say yes.
The IAM policy it needs
IAM and Access Analyzer reads. iam:GenerateServiceLastAccessedDetails starts a report job and changes no IAM entity (AWS's IAMReadOnlyAccess grants it too); access-analyzer:GenerateFindingRecommendation is deliberately left out. This is leastpriv/iam/leastpriv-read-only-policy.json, verbatim; the CLI refuses any call outside it before the request is built:
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "DawnfixLeastprivReadOnly",
"Effect": "Allow",
"Action": [
"access-analyzer:GetFindingV2",
"access-analyzer:ListAnalyzers",
"access-analyzer:ListFindingsV2",
"iam:GenerateServiceLastAccessedDetails",
"iam:GetPolicy",
"iam:GetPolicyVersion",
"iam:GetRole",
"iam:GetRolePolicy",
"iam:GetServiceLastAccessedDetails",
"iam:ListAttachedRolePolicies",
"iam:ListRolePolicies"
],
"Resource": "*"
}
]
}
IAM read access is sensitive in itself: give this to a separate role you assume only for the run.
Set up Dawnfix (https://github.com/dawnfix/dawnfix), the source-available AI SRE, in this GitHub repo and try it once. Follow prompts/setup.md in that repo, step by step. In short: npx dawnfix init writes .dawnfix.yml and a 15-line workflow that calls dawnfix/dawnfix/.github/workflows/dawnfix.yml@v0. Then comes a read-only cloud role, then two repo settings set by name. For the local CLI, run pip install dawnfix==0.5.0. Rules: - Before you change anything (a file, a cloud role, a repo variable, a commit, a PR), tell me exactly what you will change and wait for my yes. - Least privilege: the AWS role or GCP identity must be read-only. Check the AWS role with infra/aws/verify_readonly.py from the Dawnfix repo, and stop if it fails. Never widen a policy to make it pass. - Never ask me to paste a secret into this chat, and never print one. I set my AI API key (Claude today) myself with gh secret set DAWNFIX_AI_API_KEY, and DAWNFIX_ENTERPRISE_KEY only if I have Enterprise. - Start with autonomy: diagnose in .dawnfix.yml (issues only, no code changes). Never push to the default branch; everything goes through a PR I review. - Tell me what it costs me: my own Claude tokens (on my AI API key), GitHub Actions minutes and small CloudWatch API charges. No Dawnfix key is needed. To try it, run this with my read-only credentials and show me the JSON it prints: dawnfix tick --config .dawnfix.yml --state "$(mktemp -d)/state.json" --baseline --dry-run Then open the setup PR.