This is not a stable version (Beta), it's still under development
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.
See CONTRIBUTING for more information.
Read Guard Rail: Rule Development for more information on how to write resource schema rules.
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;
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
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 specifiedARN002
: arn related property MUST have pattern specifiedCOM001
: ensure_properties_do_not_support_multitypePID001
: primaryIdentifier MUST existPID002
: primaryIdentifier MUST contain valuesPR005
: primaryIdentifier MUST have properties defined in the schemaPR007
: readOnlyProperties MUST have properties defined in the schemaPER003
: Resource MUST implement read handlerPER004
: Resource MUST NOT specify wildcard permissions for read handlerPER010
: Resource MUST implement list handlerPER011
: Resource MUST NOT specify wildcard permissions for list handler
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
*Additionally, you can specify format
argument, which will produce a nicely formatted output.
Use following commands
$ git clone [email protected]:aws-cloudformation/resource-schema-guard-rail.git
python3 -m venv env
source env/bin/activate
pip install -e . -r requirements.txt
pre-commit install
# run all hooks on all files, mirrors what the CI runs
pre-commit run --all-files
This project is licensed under the Apache-2.0 License.
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: