Policy Settings

Policy settings tell Guardrails what to do with a specific policy type at a specific point in the resource hierarchy. Each setting has a value (what the policy should be), a resource (where it applies), and a precedence (how strongly it applies). Together, these determine how controls evaluate every resource in your environment.

You can set a simple static value (like Enforce: Enabled) or use a calculated policy to dynamically compute the value based on resource metadata.

Guides

GuideDescription
Create a Policy SettingCreate a new policy setting on a resource using the Guardrails console or Terraform.
Create a Calculated PolicyUse GraphQL queries and Nunjucks templates to dynamically compute policy values based on resource data.
Update a Policy SettingChange the value, precedence, or other attributes of an existing policy setting.
Delete a Policy SettingRemove a policy setting and revert to the inherited or default value.
Create an ExceptionOverride a required policy setting for a specific resource lower in the hierarchy.

Precedence

Every policy setting has a precedence that determines how it interacts with other settings in the hierarchy:

Guardrails resolves the effective value for each resource by walking up the hierarchy from the resource to the workspace root. The most specific Required setting wins. If no Required setting exists, the most specific Recommended setting wins. If no settings exist at all, the policy type's default value applies.

Calculated Policies

While most policy settings use a simple static value, calculated policies let you dynamically determine the value based on the actual properties of each resource in scope. They are defined by two components:

  1. A GraphQL query that automatically pivots to the current resource, simplifying the query syntax. You write the query once, and Guardrails runs it against each resource individually, so a query like { resource { tags } } returns the tags for whichever resource is being evaluated.

  2. A Nunjucks template that defines the logic to parse the query response and output a valid policy value. The template receives the query results and uses conditional logic to produce the final value (e.g., Check: Enabled for production resources, Skip for everything else).

This combination is powerful. You can create a single policy setting that behaves differently for thousands of resources based on their tags, configuration, region, or any other queryable attribute. Any policy in Guardrails can use a calculated policy instead of a static value.

For a step-by-step walkthrough, see Create a Calculated Policy.

Exceptions

The resource hierarchy allows you to define a policy setting in a single place and have it enforced on all descendant resources. However, there are occasions when the policy setting should not (or cannot) be enforced on specific resources. Exceptions allow you to override a Required setting on a resource lower in the hierarchy, for example, exempting a legacy application from a versioning requirement while still enforcing it everywhere else.

Exceptions can include an optional expiration date for temporary overrides. See Create an Exception.

Further Reading