Validate AWS Policies¶
A command-line tool that validates AWS IAM policies with the
IAM Access Analyzer
ValidatePolicy API and the Access Analyzer custom policy checks, and writes reports for
people and for CI/CD pipelines.
Features¶
- Policy types: identity, resource, service control (SCP) and resource control (RCP) policies, with resource-specific checks for S3 buckets, access points, role trust policies and DynamoDB tables.
- Custom policy checks: fail a build when a policy grants new access compared to a baseline, grants access you have forbidden, or can be public.
- Reports: JSON, text, HTML, Markdown, JUnit XML (CodeBuild, Azure Pipelines, Jenkins, GitLab) and SARIF (GitHub code scanning).
- Pipeline friendly: specific exit codes,
--fail-onseverity thresholds,--dry-run, JSON logs, S3 upload and ZIP archives. - Configuration: command line, YAML or TOML file, and environment variables, with a documented precedence.
- Compatible: upgrading within a major version never removes a flag, config key or exit code. Newer API features are used only when your installed boto3 supports them.
Quick start¶
pip install validate-aws-policies
# Validate every *.json file in a directory (output is JSON on stdout)
validate-aws-policies --policies-path ./policies --profile my-profile
# Self-contained HTML report
validate-aws-policies -d ./policies -p my-profile --format html
# Service control policies, failing the build on any warning
validate-aws-policies -d ./scps --policy-type scp --fail-on warning
# Block pull requests that grant more access than the baseline
validate-aws-policies -d ./policies --check-no-new-access --reference-path ./baseline
Requirements¶
- Python 3.9 or newer
- AWS credentials (profile, SSO or environment) allowed to call
access-analyzer:ValidatePolicy. Custom checks and S3 upload need more permissions, see Installation.
Where to go next¶
| I want to... | Read |
|---|---|
| Install and set up AWS access | Installation |
| Run it and read the output | Usage |
| Use a config file or environment variables | Configuration |
| Validate SCPs, trust policies or bucket policies, or add custom checks | Policy Types & Custom Checks |
| Copy a working command or pipeline | Examples, AWS CodeBuild, JUnit XML |
| Call it from Python or look up every option | API Reference |
| Contribute or cut a release | Development |
Example output¶
The recording runs version 4.0 against a real AWS account: policy files, policy types, a Terraform plan, a CloudFormation template, custom checks and reports. You can pause it and copy text, or open it on asciinema.org.
Open the sample HTML report to see the report format.
License and support¶
Apache License 2.0, see LICENSE. Report problems or ask questions in GitHub Issues. Pull requests are welcome, see Development.