Skip to main content

CloudFormation - Resource Schema Guard Rail

Apache 2.0 License Pull Request CI PyPI PyPI - Python Version

Notes

This is not a stable version (Beta), it's still under development

Overview

AWS CloudFormation Resource Schema Guard Rail is an open-source tool, which uses CloudFormation Guard policy-as-code evaluation engine to assess resource schema compliance. It validates json resource schemas against the AWS CloudFormation modeling best practices.

Contribute

See CONTRIBUTING for more information.

Rule Development

Read Guard Rail: Rule Development for more information on how to write resource schema rules.

How to use it?

Schema guard rail package has a built-in library of rules, that CloudFormation believe are the best practices that resource modelers should follow. It supports two types of evaluation - Basic Linting & Breaking Change;

Basic Linter (Stateless)

Linter works only with current version of resource schema and runs CloudFormation authored rules, which will highlight problematic schema constructs. A provider developers can run multiple independent schemas at once as well as attach custom rules.

In order to start using Basic Linting you need to run following command:

$ guard-rail --schema file://path-to-schema-1 --schema file://path-to-schema-2 --rule file://path-to-custom-ruleset1 --rule file://path-to-custom-ruleset2

Read-Only Resource Checks

For read-only resources, you can use the --is-read-only flag to run only the essential checks:

$ guard-rail --schema file://path-to-schema --is-read

When --is-read-only is specified, only the following checks are performed:

  • ARN001: arn related property MUST have pattern specified
  • ARN002: arn related property MUST have pattern specified
  • COM001: ensure_properties_do_not_support_multitype
  • PID001: primaryIdentifier MUST exist
  • PID002: primaryIdentifier MUST contain values
  • PR005: primaryIdentifier MUST have properties defined in the schema
  • PR007: readOnlyProperties MUST have properties defined in the schema
  • PER003: Resource MUST implement read handler
  • PER004: Resource MUST NOT specify wildcard permissions for read handler
  • PER010: Resource MUST implement list handler
  • PER011: Resource MUST NOT specify wildcard permissions for list handler

List of Linting Rules

Breaking Change (Stateful)

Along with basic linting, guard rail supports capability of breaking change evaluation. Provider developer must provider two json objects - previous & current versions of the same resource schema. CloudFormation authored rules will be run and evaluation current version of the schema whether it is compliant or not.

In order to start using Breaking Change evaluation you need to run following command:

$ guard-rail --schema file://path-to-schema-1 --schema file://path-to-schema-2 --rule ... --stateful

List of Breaking Change Rules

*Additionally, you can specify format argument, which will produce a nicely formatted output.

IDE Experience

Guard Rail provides IDE extensions for real-time validation of CloudFormation resource schema files directly in your development environment. Get instant feedback with inline diagnostics, error highlighting, and validation status as you write your schemas.

Supported IDEs

IntelliJ IDEA IntelliJ IDEA Plugin

Real-time validation for IntelliJ IDEA with automatic validation on file open, edit, and save. Features include inline diagnostics, status bar widget, and integration with IntelliJ's Problems tool window.

View IntelliJ Extension Documentation →

VS Code VS Code Extension

Real-time validation for Visual Studio Code with smart debouncing and inline diagnostics. Features include automatic validation, status bar integration, and manual validation commands.

View VS Code Extension Documentation →

Both extensions require the Guard Rail CLI tool to be installed (pip install resource-schema-guard-rail).

How to install it locally?

Use following commands

Clone github repo

$ git clone git@github.com:aws-cloudformation/resource-schema-guard-rail.git

Create Virtual Environment & Activate

python3 -m venv env
source env/bin/activate

Install Package Locally from the root

pip install -e . -r requirements.txt
pre-commit install

Run CI Locally

# run all hooks on all files, mirrors what the CI runs
pre-commit run --all-files

License

This project is licensed under the Apache-2.0 License.

Community

Join us on Discord! Connect & interact with CloudFormation developers & experts, find channels to discuss and get help for our CLI, cfn-lint, CloudFormation registry, StackSets, Guard and more:

Join our Discord

Release files for resource-schema-guard-rail 0.0.22

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

Source distribution (sdist)

Source distribution for resource-schema-guard-rail 0.0.22
File Size Uploaded
resource_schema_guard_rail-0.0.22.tar.gz 24.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for resource-schema-guard-rail 0.0.22
File Interpreter ABI Platform
resource_schema_guard_rail-0.0.22-py3-none-any.whl Python 3 none any Details

Total release size: 56.2 kB

Release files / resource_schema_guard_rail-0.0.22.tar.gz

Download URL resource_schema_guard_rail-0.0.22.tar.gz
Size 24.8 kB
Tags Source
SHA-256 checksum
How to use checksums
9cabf10fe9a5dc7d8ccb151f78ef62a72e72ddf4a4b38f976de130eaac22368d
BLAKE2b-256 checksum
How to use checksums
09459bec52147401045d4993e5d96dd40599dfb1de7bb0f23f23b46ce24a5735
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.7

Release files / resource_schema_guard_rail-0.0.22-py3-none-any.whl

Download URL resource_schema_guard_rail-0.0.22-py3-none-any.whl
Size 31.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4b53916fb12b7a0060e11f7db8cc37546d84315888200fccd85c9aebdde1cd70
BLAKE2b-256 checksum
How to use checksums
00f248cd66424d0798ca450d3d109361897d19fc3e19fd0e3ec8eebdf5ea8358
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.7

Release history Release notifications | RSS feed

This release

0.0.22 This release

2 release files

0.0.21

1 release file

0.0.20

2 release files

0.0.18

2 release files

0.0.17

2 release files

0.0.14

2 release files

0.0.13

2 release files

0.0.11

2 release files

0.0.10

2 release files

0.0.9

2 release files

0.0.8

2 release files

0.0.7

2 release files

0.0.6

2 release files

0.0.5

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