Policy Sentry turns an ARN and an access level into an IAM policy, and stops at what the AWS docs table can express
IAM Least Privilege Policy Generator
At a glance
- What is it?
- Policy Sentry from Salesforce is a Python CLI and library that builds AWS IAM policies from resource ARNs sorted by access level. This review covers the YAML template, the local database, the install paths and the places where the Dockerfile and the package metadata disagree.
- Who is it for?
- Use Policy Sentry if your team writes IAM policies by hand for Terraform or CloudFormation and can name the ARNs each role needs. Skip it if you expect a tool that watches API calls and derives permissions for you, because it only maps ARNs and access levels.
- Can I use it commercially?
- Yes. MIT is a permissive licence: you can use, modify and sell software built on it, as long as you keep its copyright and licence notices.
- Is it still maintained?
- Yes. The repository last received commits 14 days ago.
- What is it written in?
- Mainly Python, according to GitHub's language statistics.
Answers come from the project's GitHub data, last synced on November 24, 2026, and from our analysis. They are not legal advice.
Star history
- salesforce/policy_sentry2,174 ★ · +1
| Repository | 2026-10-08 | 2026-11-24 |
|---|---|---|
| salesforce/policy_sentry | 2.2k | 2.2k |
1 Stars in the last 47 days, measured from the daily GitHub snapshot. Compare with other projects
Editorial analysis
One database built from the AWS Actions, Resources, and Condition Keys pages
Policy Sentry reads the AWS documentation page titled Actions, Resources, and Condition Keys for AWS Services and folds it into a single local database. Each row ties an action to an access level and a resource type. ssm:GetParameter is Read on a parameter, ssm:DescribeParameters is List, ssm:PutParameter is Write, secretsmanager:PutResourcePolicy is Permissions management on a secret, and secretsmanager:TagResource is Tagging.
The policy writer then works backwards from that table. You hand it an ARN and an access level, it looks up every action whose resource type matches that ARN and whose access level matches your request, and it emits those actions with the ARN as the resource constraint. The author's own description of the alternative is the habit this replaces: reading the AWS IAM documentation page by page, giving up under deadline pressure, and either attaching a Managed Policy or guessing at wildcards.
The repository carries two helper scripts for the data side, utils/download_docs.py and utils/copy_docs.py, wired into the justfile as download-latest-aws-docs and the first step of the integration init target. The download script is how the maintainers refresh that data.
The crud template asks for ARNs under six access-level keys
Everything starts from a YAML file. The command below writes a blank one:
policy_sentry create-template --output-file crud.yml --template-type crudThe file opens with a mode and a name, then one list per access level. You paste ARNs under read, write, list, tagging and permissions-management:
mode: crud
name: ''
# Specify resource ARNs
read:
- ''
write:
- ''
list:
- ''
tagging:
- ''
permissions-management:
- ''Below that sits a wildcard-only block with single-actions, service-read, service-write and service-list entries. It exists for actions that AWS does not allow you to scope to a resource. Those cannot carry an ARN constraint, so the template gives them a separate place and keeps them visibly apart from the scoped statements.
The three example requests in the README show the intended granularity: Read, Write and List on arn:aws:s3:::example-org-sbx-vmimport, Permissions Management on a Secrets Manager secret ARN, and Tagging on an SSM parameter ARN. One ARN per intent, no action names anywhere in the input.
write-policy is the only step that produces JSON, and examples/yml/crud.yml is the reference input
After the template is filled in, the write-policy subcommand takes it as input. The justfile's integration target runs it against the checked-in sample:
uv run ./policy_sentry/bin/cli.py write-policy --input-file examples/yml/crud.ymlThat sample is the quickest way to see what a finished template looks like, since examples/yml/ sits next to examples/analyze/, examples/library-usage/ and examples/asciinema/. The Python library route exists for teams that would rather call the writer from code than shell out, and examples/library-usage/ is where its usage lives.
The tutorial in the README stops at three steps: create the template, copy and paste ARNs, run write-policy. Nothing in it covers feeding the output to AWS or validating it afterward. Policy Sentry produces a policy document and your pipeline has to do the rest, including checking that the result is the narrow policy you intended.
Query subcommands expose the database for people who still want to read it
The same database answers lookups through a query command with three tables. The justfile lists exact invocations for each:
uv run ./policy_sentry/bin/cli.py query action-table --service ram
uv run ./policy_sentry/bin/cli.py query action-table --service ram --name tagresource
uv run ./policy_sentry/bin/cli.py query action-table --service ram --access-level permissions-management
uv run ./policy_sentry/bin/cli.py query action-table --service ssm --resource-type parameter
uv run ./policy_sentry/bin/cli.py query action-table --service ssm --access-level write --resource-type parameter
uv run ./policy_sentry/bin/cli.py query action-table --service ses --condition ses:FeedbackAddressFilters combine. You can ask for every ssm action that is Write on a parameter, or every ses action tied to the ses:FeedbackAddress condition key. The arn-table subcommand takes --service, --name and --list-arn-types, and condition-table takes --service and --name, for example --name cloud9:Permissions.
These lookups matter when the generated policy surprises you. If an action shows up that you did not expect, the action-table query tells you which access level AWS filed it under, and that is the whole reason it was included.
Local initialization is optional, and the integration targets show what it creates
The README marks local initialization as optional, and the justfile makes the mechanics visible. The init target runs utils/copy_docs.py and then the initialize subcommand of cli.py. The matching clean target deletes the whole directory with rm -rf "$HOME/.policy_sentry/".
So the database lives in a dot-directory under your home folder, and wiping it is a single rm. That is convenient on a laptop and awkward in CI, where a fresh runner has no such directory and the first command either needs an initialize step or has to rely on the data bundled with the package. The README does not say which of the two applies to a plain pip install, so confirm it on a throwaway machine before putting write-policy into a pipeline.
Shell completion is a separate, smaller setup. For Bash, add this line to .bashrc:
eval "$(_POLICY_SENTRY_COMPLETE=bash_source policy_sentry)"For ZSH, the line in .zshrc uses zsh_source in place of bash_source. The completion script is generated by click, which is one of the declared dependencies.
Homebrew taps the repository itself, while pip installs the policy_sentry package
Two install paths are given. Homebrew needs a tap that points at the GitHub repository, which is why HomebrewFormula/ sits in the repository root:
brew tap salesforce/policy_sentry https://github.com/salesforce/policy_sentry
brew install policy_sentryPip is the other:
pip3 install --user policy_sentryThe --user flag installs into your user site directory, so the policy_sentry executable may not be on your PATH until that directory is added. The entry point is declared in pyproject.toml as policy_sentry.bin.cli:main. The project name on PyPI is written policy-sentry with a hyphen, which pip normalizes.
The build backend is hatchling, and the runtime dependencies are beautifulsoup4, click, orjson, pyyaml, requests and schema, each pinned with an upper bound at the next major version, with schema held below 0.8. Python 3.10 is the minimum, and the classifiers go up to 3.14. The most recent releases are 0.16.0 on 2026-04-14, then 0.15.1 and 0.15.0 on 2025-12-02.
The Dockerfile still pins Python 3.9 while pyproject.toml demands 3.10
The Dockerfile in the repository root starts from this line:
ARG FROM_TAG=3.9-slim
FROM python:${FROM_TAG}The package metadata says requires-python = ">=3.10". A default build of the image therefore starts from an interpreter below the declared minimum, unless you override FROM_TAG at build time. Anyone who builds with docker build -t policy_sentry . and gets an install error should pass a newer tag first.
There are other rough edges in that file. It still carries a MAINTAINER instruction naming Kinnaird McQuade. It copies a requirements.txt into /tmp, while the top-level listing shows pyproject.toml and uv.lock as the dependency sources and no requirements.txt. The visible list of repository entries does not include one, so a clean checkout may fail at that COPY step. The justfile's docker-build target runs the plain docker build and nothing more.
The container sets utils/entrypoint.sh as the entrypoint and --help as the default command, so running the image with no arguments prints usage instead of doing work.
Terraform and the access-level model leave gaps you have to cover
A terraform_module/ directory ships in the repository, and the README's table of contents lists Terraform as its own usage section. That is the natural home for the tool, since the people described in the overview are Infrastructure as Code developers who write policies for roles and users.
The model has hard limits. Input is an ARN plus an access level, so a requirement such as allowing a single API call on a single resource needs the wildcard-only block or a hand edit. Condition keys appear in the query output but the crud template has no field for them. The tool does not observe your AWS API calls either. The author says as much: there is no automated tool that senses what your code calls and writes the policy with ARN constraints, and Policy Sentry does not fill that gap. You still decide which resources each role touches.
Maintenance looks steady: the repository is not archived, and the last push was on 2026-10-08.
Editorial conclusion
Use Policy Sentry if your team writes IAM policies by hand for Terraform or CloudFormation and can name the ARNs each role needs. Skip it if you expect a tool that watches API calls and derives permissions for you, because it only maps ARNs and access levels. Before adopting it, build the Docker image from the Dockerfile and confirm it matches the Python 3.10 floor in pyproject.toml.
Frequently asked questions
What is an example of an IAM policy that Policy Sentry generates?
Asking for Read, Write and List access to arn:aws:s3:::example-org-sbx-vmimport produces a policy scoped to that bucket ARN with the S3 actions at those access levels. Policy Sentry fills the actions in from its AWS documentation database.
What is an AWS managed policy and how does Policy Sentry avoid it?
The README describes developers reaching for Managed Policies, or guessing at wildcards, to save time. Policy Sentry generates a scoped policy from ARNs and access levels in seconds, which is its alternative to that shortcut.
What is the IAM policy Policy Sentry writes meant to limit?
The policies are scoped by access level and resource so that, if credentials are compromised, the principal can reach only what it needs. That limits the blast radius of a breach.
Official sources
Add this badge to your README
If you maintain this project, the badge below links readers to this analysis and shows its maintenance status from the daily GitHub snapshot. Paste the markdown into your README; add ?metric=license or ?metric=stars to the image URL for a different field.
[](https://hysenlabs.com/projects/salesforce-policy-sentry)Star history chart for your README
[](https://hysenlabs.com/projects/salesforce-policy-sentry)Was this useful?