Skip to main content

aws-guardrails

aws-guardrails is a small Python package for catching broken AWS infrastructure documents before they reach review or deployment.

Current scope:

  • IAM JSON policy syntax and structure validation
  • CloudFormation JSON/YAML syntax validation
  • Duplicate-key detection for JSON and YAML mappings
  • CloudFormation-aware YAML parsing for intrinsic tags such as !Ref and !Sub
  • invalid IAM action detection with typo and wrong-service suggestions
  • IAM security best-practice checks for public access and risky policy constructs
  • IAM least-privilege checks for wildcard actions, wildcard resources, and iam:PassRole
  • CloudFormation checks for sensitive parameters and embedded IAM policies

Planned next scope:

  • more AWS service-specific privilege-escalation patterns
  • deeper CloudFormation resource configuration checks
  • optional policy packs and CI fail thresholds

Install

pip install .

Usage

Validate a single IAM policy:

aws-guardrails validate examples/policy.json --kind iam

Validate a single CloudFormation template:

aws-guardrails validate examples/template.yaml --kind cloudformation

Validate a whole folder recursively:

aws-guardrails validate ./infra/

Validate a mixed set of files and folders in one run:

aws-guardrails validate ./iam/policy.json ./cfn ./shared/templates

Auto-detect document type:

aws-guardrails validate path/to/file-or-directory

Emit machine-readable output:

aws-guardrails validate templates/ --format json

What it flags

  • syntax errors in IAM JSON and CloudFormation JSON/YAML
  • duplicate keys in JSON and YAML mappings
  • invalid IAM action names such as ec2:CreateRole
  • probable IAM action typos such as s3:GetObejct
  • Allow statements with Action: "*" or broad service wildcards
  • Allow statements using NotAction, NotResource, or NotPrincipal
  • public resource policies using Principal: "*"
  • risky iam:PassRole permissions
  • CloudFormation sensitive parameters without NoEcho
  • literal default secrets in CloudFormation parameters
  • IAM policy misuse inside CloudFormation role, managed policy, and policy resources

Example

aws-guardrails validate bad-policy.json --kind iam

Example output:

FAIL bad-policy.json [iam]
  - ERROR IAM033 Statement[0].Action uses unknown action 'ec2:CreateRole'.
    Fix: Did you mean 'iam:CreateRole'?

Summary: scanned 1 file(s), clean 0, warning-only 0, failed 1.

Exit codes

  • 0: all files passed validation
  • 1: one or more validation errors were found
  • 2: CLI usage or runtime error

ERROR and SECURITY findings fail validation. WARNING findings are advisory.

Release files for aws-guardrails 0.1.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 aws-guardrails 0.1.0
File Size Uploaded
aws_guardrails-0.1.0.tar.gz 117.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for aws-guardrails 0.1.0
File Interpreter ABI Platform
aws_guardrails-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 233.6 kB

Release files / aws_guardrails-0.1.0.tar.gz

Download URL aws_guardrails-0.1.0.tar.gz
Size 117.7 kB
Tags Source
SHA-256 checksum
How to use checksums
feed2184171acb4711add2703702d400723146d9193569abebe5ef869783c4dd
BLAKE2b-256 checksum
How to use checksums
1548401d6c3e3576e1d4dc26f9f56d59097b5827bb74a50d467fb87d4ba0b833
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.0

Release files / aws_guardrails-0.1.0-py3-none-any.whl

Download URL aws_guardrails-0.1.0-py3-none-any.whl
Size 115.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a456b57e49c3860b865529582f9ca9f896f9b8c7ef3a746ec1e56ffc9932b74b
BLAKE2b-256 checksum
How to use checksums
a11a21fbae906c93f2209f543b2479b4f268142a1641cb2d84129794bc566036
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.0

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

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