This feature is only available on Chainloop’s platform paid plans.
Overview
Chainloop supports a GitOps workflow for its configuration. You don’t create policies, frameworks, contracts, and workflow templates one by one in the UI. Instead, you define them as YAML files in a Git repository and apply them with thechainloop apply command. The repository is the source of truth, and Chainloop follows it. This means you can:
- Version-control every change, with its history and author
- Review changes through pull requests before they take effect
- Automate the rollout from CI/CD when a change merges
- Reproduce the same configuration across organizations and environments
apiVersion, kind, metadata, and spec fields. Apply operations are idempotent: if a resource with the same name already exists, Chainloop updates it. Otherwise, Chainloop creates it. Applying an unchanged file changes nothing.
What You Can Manage
chainloop apply manages the resources below. They fall into two groups that you can use together or on their own: the compliance resources (policies, policy groups, requirements, and frameworks), and the resources that define how your workflows attest (contracts and workflow templates). You don’t need a framework to manage contracts as code.
chainloop apply doesn’t manage other resources, such as projects and workflows. Create a workflow with chainloop workflow create --contract <name> to use a contract that you manage as code.
Example Repository Layout
Keep your resources in a dedicated folder of a Git repository, one folder per kind. The layout below is a good starting point:- One folder per policy. Keep the Rego code in
.regofiles next to the policy YAML and reference them withpath, which is relative to the policy file.chainloop policy develop init --directory policies/<name> --name <name>creates this layout for you. See How to write custom policies. You can then test the Rego withopa testin CI before you apply it. - One resource per file, named after the resource. Name each file after its
metadata.name, for examplecontracts/build-contract.yamlfor the contractbuild-contract. A framework and its requirements can share one multi-document file. - Any folder structure works.
chainloop applyreads every YAML file under the path that you give it and applies the resources in dependency order. The folders are only for people.chainloop applyskips files that are not YAML, and YAML files without akind, such as CI configuration.
Prerequisites
Before you begin, make sure you have:- Chainloop CLI Enterprise Edition installed - see the CLI installation guide
- Authenticated to your organization - run
chainloop auth login
Walkthrough: Compliance as Code
This walkthrough builds a complete compliance-as-code setup from scratch around an SBOM license-compliance use case. Each step builds on the previous one. By the end, you’ll have a policy, a policy group, a requirement, a framework, and a contract that all work together. The steps below apply each resource individually so you can verify as you go. In practice, you can place all your YAML files in a single directory and apply them at once withchainloop apply -f ./chainloop/ - Chainloop resolves dependencies automatically. See Applying Resources at Scale.
Step 1 - Write a Policy
A policy contains the Rego rules that Chainloop evaluates against your attestation materials. Start by defining one that checks CycloneDX SBOMs for components missing license information. Createcyclonedx-licenses.yaml:
Step 2 - Group Policies Together
A policy group bundles related policies into a reusable unit. Let’s create one that groups thecyclonedx-licenses policy from Step 1 with another SBOM policy to form a complete SBOM quality check.
Create sbom-quality-group.yaml:
cyclonedx-licenses policy you just created alongside sbom-banned-licenses, a built-in policy that ships with Chainloop. The attestation section checks that an SBOM was included in the attestation; the materials section runs quality checks against the SBOM itself.
Apply and verify:
Step 3 - Define a Requirement
A requirement specifies what must be satisfied for compliance - which policies to evaluate, how often, and what manual evidence is needed. Let’s create one that enforces license compliance by referencing the policy from Step 1. Createlicense-compliance.yaml:
periodicity (how often a policy is re-evaluated, e.g. daily, weekly), sla (grace period in hours before failures affect the compliance score), group (to organize policies into groups where any member passing satisfies the group), and manual_proofs for evidence that can’t be automated (e.g., license review sign-offs). For the full schema, see Compliance Frameworks.
Apply and verify:
Step 4 - Build a Framework
A framework organizes requirements into a structured compliance program. You can group requirements into sections (and nested sub-sections) to model standards like CRA, SLSA, or your own internal policies. Let’s build one that includes the requirement from Step 3. Createbest-practices.yaml:
branch-protection, code-review) with the custom license-compliance requirement you created in Step 3. Chainloop ships with a library of built-in requirements and policies - your custom resources extend them.
Apply and verify:
Each requirement can only appear once in a framework - either at the root level or within a section, not both.
Step 5 - Tie It Together in a Contract
A contract defines the attestation expectations for a workflow - what materials to collect and which policies and policy groups to evaluate. This is where everything comes together: the contract references the policy group from Step 2, which in turn includes the policy from Step 1. Createexample-contract.yaml:
Managing Contracts Declaratively
A contract can stand on its own: it lists the materials and annotations that a workflow’s attestations must include, and optionally the policies to evaluate. Createbuild-contract.yaml:
Applying Resources at Scale
The steps above apply resources one at a time. Thechainloop apply command can handle any resource type, including multi-document YAML files and entire directories:
When applying multiple resources, Chainloop processes them in dependency order: Policies, then Requirements, Frameworks, Policy Groups, Contracts, and Workflow Templates. Multi-document YAML files use
--- as the separator between resources.Inspecting and Exporting Resources
After applying resources, you can verify them, explore what’s deployed, and export definitions for backup or migration. Export a resource as reusable YAML with the--output schema flag - useful for bootstrapping new configurations, backing up resources, or migrating between organizations:
Automating with CI/CD
Store your YAML resource definitions in a git repository and apply them automatically whenever changes are merged. This keeps your Chainloop configuration up to date and auditable. You’ll need an API token stored as a CI secret.- GitHub Actions
- GitLab CI
