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:
- Cost center mappings, a lookup table that maps account IDs to cost centers, so tagging policies can automatically apply the correct
CostCentertag. - Application ownership, a registry of application names and their owners, so policies can tag resources with the responsible team.
- Custom environment labels, a mapping from account IDs to environment names (e.g.,
prod,staging,sandbox) that aren't captured in cloud provider metadata. - Inventory data from external systems, data pulled from a CMDB, asset management tool, or HR system that policies need to reference.
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
| Property | Description |
|---|---|
| Title | The display name of the file (stored in metadata). |
| Description | An optional description (stored in metadata). |
| AKA | A user-defined alias that calculated policies use to reference the file by name (e.g., cost_centers, app_owners). |
| Data | The file content, any valid JSON object. |
| Parent | The parent resource. Files can be children of the Turbot workspace root or any folder. |
How Files Work
- Create a file with a unique AKA and JSON data. You can create files through the GraphQL API or Terraform.
- Reference the file in a calculated policy's
template_inputquery using its AKA:resource(id: "my-file-aka") { data }. - 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
| Guide | Description |
|---|---|
| Create a File via GraphQL | Create a file programmatically using the GraphQL API. |
| Create a File via Terraform | Manage files as infrastructure-as-code with the Guardrails Terraform provider. |
| Use a File in a Calculated Policy | Reference file data in calculated policies using GraphQL queries and Nunjucks templates. |