Skip to main content

Validate AWS policies

This package validates AWS IAM policies (identity, resource, SCP and RCP) with the IAM Access Analyzer ValidatePolicy API and creates reports in HTML, Markdown or JUnit XML format.

Pre-Requirements

Setup AWS Cli profile for interacting with IAM access analyzer API using IAM or SSO credentials.

Requirements

  • python >= 3.8

Install

$ pip install --upgrade validate-aws-policies

From AWS CodeArtifacts repository

You must have a user into AWS account Sophos Organization, it could be for projects, products, or IT internal Organizations. Before create AWS CLI profile using AWS IAM Identity Center (SSO) or IAM.

  1. Configure your pip cli for download package from private CodeArtifacts repository
$ aws codeartifact login --tool pip --repository <repository_name> --domain <domain> --domain-owner <123456789012>  --profile <profile_name> --region <repository_region>
$ pip install --upgrade validate-aws-policies

From Azure Artifacts repository

Project setup

Ensure you have installed the latest version of the Azure Artifacts keyring from the "Get the tools" menu.

If you don't already have one, create a virtualenv using these instructions from the official Python documentation. Per the instructions, "it is always recommended to use a virtualenv while developing Python applications."

Add a pip.ini (Windows) or pip.conf (Mac/Linux) file to your virtualenv

[global]
index-url=https://pkgs.dev.azure.com/<organizations>/.../_packaging/.../pypi/simple/

Instructions

validate-aws-policies -h
usage: validate-aws-policies [-h] [-v] [--config FILE] [-d PATH] [-t {identity,resource,scp,rcp}]
                             [-p NAME] [-f {json,text,html,md,markdown,xml,junit,sarif,all}] [-o FILE] [-z]
                             [-u] [-b NAME] [-c] [--dry-run] [--verbose | --quiet]
                             [--log-format {text,json}]

options:
  -h, --help            show this help message and exit
  -v, --version         Print the package version and exit
  --config FILE         Path to configuration file (YAML or TOML format)
  -d, --policies-path PATH
                        Directory path containing policy files in JSON format
  -t, --policy-type {identity,resource,scp,rcp}
                        Type of policies in the directory (default: identity)
  --resource-type TYPE  Resource type for resource policies (s3-bucket, trust-policy, ...)
  --locale LOCALE       Language of the finding messages (default: EN)
  --max-findings N      Collect at most N findings per policy (default: all)
  -r, --recursive       Also validate *.json files in sub-directories
  --continue-on-error   Validate everything, write reports, then exit 1 on any ERROR
  --fail-on LEVEL       Exit 1 at this severity or higher: error, security-warning,
                        warning, suggestion, none
  -p, --profile NAME    AWS CLI profile name for Access Analyzer API
  -f, --format          Output format (default: json). Use xml/junit for CI/CD integration
  -o, --output FILE     Output file path
  -z, --zip             Create ZIP archive of generated reports
  -u, --upload          Upload generated reports to S3 bucket
  -b, --bucket NAME     S3 bucket name (required with --upload)
  -c, --ci              Run in CI/CD pipeline mode
  --dry-run             Validate without creating reports or uploading
  --verbose / --quiet   DEBUG or ERROR-only logging
  --log-format          Log output format: text or json

custom policy checks (identity and resource policies; billed per API call):
  --check-no-new-access        Fail if a policy grants more than its baseline in --reference-path
  --check-access-not-granted   Fail if --deny-actions / --deny-resources are granted
  --check-no-public-access RESOURCE_TYPE
                               Fail if a resource policy can be public (for example s3-bucket)

See docs/access-analyzer-features.md for policy types, custom checks, policy sets, SARIF output and CI examples.

Exit codes: 0 success, 1 validation error, 2 configuration error, 3 AWS API error, 4 file error.

Settings can also come from a YAML/TOML file (--config) and the environment variables AWS_PROFILE, REPORTS_BUCKET, POLICIES_PATH and LOG_LEVEL. Precedence, lowest to highest: defaults, config file, environment variables, CLI arguments. See config.example.yaml.

Examples

validate-aws-policies -d project_configurations/policies/ -p sh-devsecops --format html

# Validate service control policies and write a JUnit report for CI
validate-aws-policies -d scps/ --policy-type scp --format xml

# Fail a pull request when a policy grants more access than the baseline
validate-aws-policies -d policies/ --check-no-new-access --reference-path baseline/ --format sarif

Example_validate_pol

The previous command create a report in the current folder with the syntax name: AccessAnalyzerReport_2023-06-26 155116.844676.html. For example:

report

Extras

Enable autocomplete

Argcomplete provides easy, extensible command line tab completion of arguments for your Python application.

It makes two assumptions:

  • You’re using bash or zsh as your shell

  • You’re using argparse to manage your command line arguments/options

Argcomplete is particularly useful if your program has lots of options or subparsers, and if your program can dynamically suggest completions for your argument/option values (for example, if the user is browsing resources over the network). Run:

activate-global-python-argcomplete

and to make sure that bash knows about this script, you use

echo 'eval "$(register-python-argcomplete validate-aws-policies)"' >> ~/.bashrc
source ~/.bashrc

Metadata

Release files for validate-aws-policies 3.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for validate-aws-policies 3.2.0
File Size Uploaded Provenance Actions
validate_aws_policies-3.2.0.tar.gz 316.3 kB With provenance Details for validate_aws_policies-3.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for validate-aws-policies 3.2.0
File Interpreter ABI Platform Actions
validate_aws_policies-3.2.0-py3-none-any.whl Python 3 none any Details for validate_aws_policies-3.2.0-py3-none-any.whl

Total release size: 367.5 kB

Release files / validate_aws_policies-3.2.0.tar.gz

Download URL validate_aws_policies-3.2.0.tar.gz
Size 316.3 kB
Tags Source
SHA-256 checksum
How to use checksums
7c147a9b78e14f4f0faf8b24dd15279ab168f0cae5691a9011546429120627f5
BLAKE2b-256 checksum
How to use checksums
a4a6b842f0eef09a039fe31b2dcbde0b045d9c177de15ff3d6e390d1a9a85a06
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 19, 2026.

Transparency log

Release files / validate_aws_policies-3.2.0-py3-none-any.whl

Download URL validate_aws_policies-3.2.0-py3-none-any.whl
Size 51.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ebc2bdd580cd753c32067f5893e80e543c685d9a223001e5270128a83dd1b038
BLAKE2b-256 checksum
How to use checksums
187e90fa637dadbabd4c2248db8f50f60d3a9df49831bdeac6e295f8703de1d6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 19, 2026.

Transparency log

Security for validate-aws-policies 3.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for validate_aws_policies-3.2.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 19, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page