Skip to main content

Syntax validation for IAM JSON policies and AWS CloudFormation templates.

Project description

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

aws_guardrails-0.1.0.tar.gz (117.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

aws_guardrails-0.1.0-py3-none-any.whl (115.9 kB view details)

Uploaded Python 3

File details

Details for the file aws_guardrails-0.1.0.tar.gz.

File metadata

  • Download URL: aws_guardrails-0.1.0.tar.gz
  • Upload date:
  • Size: 117.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.0

File hashes

Hashes for aws_guardrails-0.1.0.tar.gz
Algorithm Hash digest
SHA256 feed2184171acb4711add2703702d400723146d9193569abebe5ef869783c4dd
MD5 306c3c35e4641f46668e0f21c4fb555d
BLAKE2b-256 1548401d6c3e3576e1d4dc26f9f56d59097b5827bb74a50d467fb87d4ba0b833

See more details on using hashes here.

File details

Details for the file aws_guardrails-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: aws_guardrails-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 115.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.0

File hashes

Hashes for aws_guardrails-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a456b57e49c3860b865529582f9ca9f896f9b8c7ef3a746ec1e56ffc9932b74b
MD5 d91ad96517fdf6275d390f724a92e282
BLAKE2b-256 a11a21fbae906c93f2209f543b2479b4f268142a1641cb2d84129794bc566036

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page