Guardrails Files

Organizations often need to add custom data or metadata to the Guardrails CMDB for use in policies, as well as referencing arbitrary metadata across a wide range of resource types. A Guardrails File is a resource type designed for exactly this. It stores custom JSON data in your workspace that calculated policies can reference by name.

Why Use Files?

Guardrails has built-in policies for many common governance scenarios, but your organization has its own data that doesn't live in the cloud provider: asset inventories, cost center assignments, application ownership mappings, and other business metadata. Files let you bring that data into Guardrails so policies can use it.

Common examples:

Without files, you'd have to hard-code this data into every calculated policy that needs it. With files, you define the data once and reference it by name. When the data changes, every policy that references the file automatically picks up the new values. You can update files manually, through Terraform, or with automated integrations that pull data from external systems.

File Properties

PropertyDescription
TitleThe display name of the file (stored in metadata).
DescriptionAn optional description (stored in metadata).
AKAA user-defined alias that calculated policies use to reference the file by name (e.g., cost_centers, app_owners).
DataThe file content, any valid JSON object.
ParentThe parent resource. Files can be children of the Turbot workspace root or any folder.

How Files Work

  1. Create a file with a unique AKA and JSON data. You can create files through the GraphQL API or Terraform.
  2. Reference the file in a calculated policy's template_input query using its AKA: resource(id: "my-file-aka") { data }.
  3. Use the data in the policy's Nunjucks template to make dynamic decisions.

When you update the file's data, Guardrails automatically re-evaluates all policies that reference it, no policy changes needed.

Guides

GuideDescription
Create a File via GraphQLCreate a file programmatically using the GraphQL API.
Create a File via TerraformManage files as infrastructure-as-code with the Guardrails Terraform provider.
Use a File in a Calculated PolicyReference file data in calculated policies using GraphQL queries and Nunjucks templates.