Select your cookie preferences

We use essential cookies and similar tools that are necessary to provide our site and services. We use performance cookies to collect anonymous statistics, so we can understand how customers use our site and make improvements. Essential cookies cannot be deactivated, but you can choose “Customize” or “Decline” to decline performance cookies.

If you agree, AWS and approved third parties will also use cookies to provide useful site features, remember your preferences, and display relevant content, including relevant advertising. To accept or decline all non-essential cookies, choose “Accept” or “Decline.” To make more detailed choices, choose “Customize.”

test

Focus mode
test - AWS CloudFormation Guard

Validates an AWS CloudFormation Guard rules file against a Guard unit testing file in JSON or YAML format to determine the success of individual rules.

Syntax

cfn-guard test --rules-file <value> --test-data <value>

Parameters

-h, --help

Prints help information.

-m, --last-modified

Sorts by last-modified times within a directory

-V, --version

Prints version information.

-v, --verbose

Increases the output verbosity. Can be specified multiple times.

The verbose output follows the structure of the Guard rules file. Every block in the rules file is a block in the verbose output. The top-most block is each rule. If there are when conditions against the rule, they appear as a sibling condition block.

Options

-r, --rules-file

Provides the name of a rules file.

-t, --test-data

Provides the name of a file or directory for data files in either JSON or YAML format.

args

<alphabetical>

Sorts alphabetically inside a directory.

Examples

cfn-guard test \ --rules rules.guard \ --test-data rules_tests.json

Output

PASS|FAIL Expected Rule = rule_name, Status = SKIP|FAIL|PASS, Got Status = SKIP|FAIL|PASS

See also

Testing Guard rules

PrivacySite termsCookie preferences
© 2025, Amazon Web Services, Inc. or its affiliates. All rights reserved.