https://github.com/aws-cloudformation/resource-schema-guard-rail
The CloudFormation Resource Schema Guard Rail allows you to evaluate resource schema compliance against CloudFormation enforced best practices
https://github.com/aws-cloudformation/resource-schema-guard-rail
aws aws-cloudformation cfn-guard cloudformation
Last synced: about 1 year ago
JSON representation
The CloudFormation Resource Schema Guard Rail allows you to evaluate resource schema compliance against CloudFormation enforced best practices
- Host: GitHub
- URL: https://github.com/aws-cloudformation/resource-schema-guard-rail
- Owner: aws-cloudformation
- License: apache-2.0
- Created: 2022-09-21T19:24:11.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2024-04-12T18:55:24.000Z (about 2 years ago)
- Last Synced: 2024-04-14T15:23:30.117Z (about 2 years ago)
- Topics: aws, aws-cloudformation, cfn-guard, cloudformation
- Language: Python
- Homepage:
- Size: 146 KB
- Stars: 6
- Watchers: 18
- Forks: 2
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# CloudFormation - Resource Schema Guard Rail

[](https://github.com/aws-cloudformation/resource-schema-guard-rail/actions/workflows/pr-ci.yml)
[](https://badge.fury.io/py/resource-schema-guard-rail)
[](https://pypi.org/project/resource-schema-guard-rail/)
### 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](https://github.com/aws-cloudformation/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](CONTRIBUTING.md#security-issue-notifications) for more information.
#### Rule Development
Read [Guard Rail: Rule Development](docs/RULE_DEVELOPMENT.md) 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:
```bash
$ 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
```
**[List of Linting Rules](docs/BASIC_LINTING.md)**
#### 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 Basic Linting you need to run following command:
```bash
$ guard-rail --schema file://path-to-schema-1 --schema file://path-to-schema-2 --rule ... --stateful
```
**[List of Breaking Change Rules](docs/BREAKING_CHANGE.md)**
*Additionally, you can specify `format` argument, which will produce a nicely formatted output.
### How to install it locally?
Use following commands
#### Clone github repo
```bash
$ 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:
[](https://discord.gg/9zpd7TTRwq)