(Recommended) Write a Custom Rule Spec (Unit Test)
Custom Rule Specs are unit tests for your Custom Rules. As you iterate on your Custom Rules, it is recommended that you maintain unit tests. These unit tests typically include sample terraform that represents valid and invalid test cases. The following is an example Custom Rule spec for a custom rule that enforces tag requirements:
Creating a Custom Rule Spec template
Use the following CLI command:
This command introduces a series of interactive prompts and allows you to set up your Project, rule, rule spec (for testing), and resource relations. By selecting rule spec
, you will get a series of interactive prompts to create the template for your rule spec. This results in a template based on Terraform, CloudFormation, Azure Resource Manager, or Kubernetes.
Example output from interactive prompts:
Writing a Custom Rule spec
After the Custom Rule spec template is created, you must populate it with valid and invalid configurations, with the Input Type selected, such as Terraform.
Last updated