# AWS CloudFormation Guard checks JSON and YAML against rules in its own language, and blocks only through CloudFormation Hooks

Facts read 16 Nov 2026. Page reviewed 16 Nov 2026.

AWS CloudFormation Guard (cfn-guard) is an Apache 2.0 command line tool that validates JSON or YAML, such as CloudFormation templates and Terraform plans, against rules in a purpose-built language. AWS says it gives no server-side enforcement without Hooks. Release v3.2.1 is latest as read on 16 Nov 2026, dated 25 Aug 2026.

## AWS CloudFormation Guard described by eight fields, read 16 Nov 2026

| Field | Value |
| --- | --- |
| What it evaluates | Structured JSON or YAML: CloudFormation templates and change sets, Terraform JSON plans and state, Kubernetes configurations, and AWS Config configuration items |
| Where it runs | CLI in CI, as a pre-commit hook, as a GitHub Action or a Docker image; server-side enforcement uses CloudFormation Hooks |
| Policy language | Guard DSL: clauses that evaluate to true or false, grouped into rules |
| Clouds and targets | General-purpose, with an AWS Guard Rules Registry of rule sets for AWS resources |
| License | Apache License 2.0 (LICENSE file, read 16 Nov 2026) |
| Maintainer | AWS: the repository is in the aws-cloudformation GitHub organization and AWS hosts the user guide |
| Tested before enforcement | Built-in unit tests: `cfn-guard test --rules-file  --test-data ` with JSON or YAML test files |
| Current version | v3.2.1, marked Latest, released 25 Aug 2026 per the GitHub releases page |

## Guard evaluates a file, so it is a shift-left check unless wired into Hooks

AWS describes Guard as an open-source, general-purpose policy-as-code evaluation tool with a CLI. Rules can be split across several files, one per purpose such as S3, DynamoDB or access management, and run together against one input. The README names three domains: preventative governance (validate templates and Terraform plans before deployment), detective governance (validate AWS Config configuration items) and deployment safety (validate CloudFormation change sets, for example to prevent a table rename that forces a replacement).

AWS states that Guard "doesn't provide server-side enforcement" and points to CloudFormation Hooks for server-side validation, where an operation can be blocked or warned. [Control Tower proactive controls](/aws-control-tower-guardrails/) are the managed form of that route.

## Guard has a unit test framework and a scoped test file format

AWS documents test files as JSON or YAML with multiple inputs and the expected outcome for each rule, and recommends starting with empty inputs before adding cases. The README notes that Guard 3.0 changed intrinsic function handling, so tests written for earlier versions may need review, and that Guard 2.0 and later are backward incompatible with 1.0 rules.

The README says the validate command accepts a --structured flag that emits JSON or YAML output a pipeline can parse. AWS says Hooks can block or warn an operation, so a warn-first rollout is possible; the Hook settings that choose between them are outside the pages read.

## The project lists two things Guard does not do

AWS says Guard does not validate CloudFormation templates for valid syntax or allowed property values, and recommends cfn-lint for that. It also gives no server-side enforcement by itself. A rule that passes Guard can still fail at deploy time, and a template that is never passed to Guard is never checked.

The Control Tower documentation says its proactive controls, which are built on CloudFormation Hooks, evaluate the strings passed to the hook and cannot resolve secure strings or secrets. A rule about a value kept in a secret therefore needs a different check.

## Guard rules cover infrastructure code, so cloud-account guardrails sit beside them

A Guard rule on S3 encryption in a template and the [Require server-side encryption on S3 uploads](/guardrails/aws-scp-require-s3-server-side-encryption/) SCP address nearby risks at different points. See [policy as code examples](/policy-as-code-examples/) for the Guard syntax, [policy as code tools](/policy-as-code-tools/) for the other engines and [compliance as code](/compliance-as-code/) for the Config-based form.

## Related pages

- [AWS SCP examples explained: what each pattern blocks and breaks](/guides/aws-scp-examples-explained/)
- [How SCP evaluation works: allow lists, deny lists, and the limits](/guides/how-scp-evaluation-works/)
- [Resource control policies: what RCPs are and how they differ from SCPs](/guides/resource-control-policies/)
- [All of them](/guides/)

## Sources

- GitHub: aws-cloudformation/cloudformation-guard: https://github.com/aws-cloudformation/cloudformation-guard (read 16 Nov 2026)
- GitHub: CloudFormation Guard README: https://raw.githubusercontent.com/aws-cloudformation/cloudformation-guard/main/README.md (read 16 Nov 2026)
- GitHub: CloudFormation Guard releases: https://github.com/aws-cloudformation/cloudformation-guard/releases (read 16 Nov 2026)
- GitHub: CloudFormation Guard LICENSE: https://raw.githubusercontent.com/aws-cloudformation/cloudformation-guard/main/LICENSE (read 16 Nov 2026)
- AWS: what is CloudFormation Guard: https://docs.aws.amazon.com/cfn-guard/latest/ug/what-is-guard.html (read 16 Nov 2026)
- AWS: testing Guard rules: https://docs.aws.amazon.com/cfn-guard/latest/ug/testing-rules.html (read 16 Nov 2026)
- AWS Control Tower: proactive controls: https://docs.aws.amazon.com/controltower/latest/controlreference/proactive-controls.html (read 10 Nov 2026)

Last reviewed 16 Nov 2026. Canonical: https://cloudgovernancetools.com/engines/cloudformation-guard/
