Skip to content

Config-as-code

Config-as-code moves your data model, access rules and settings between CairnCMS instances. Capture the source as YAML files, review changes in source control, preview them against the target, and apply the reviewed tree.

Use cairncms config snapshot and cairncms config apply to manage these resources together in CairnCMS 1.7.0 and later.

Resource Captured state
Schema Collections, fields, relations and their metadata
Roles and permissions Role keys, access flags and operator-defined permission rules
Folders File-library folder keys, names and hierarchy
Project settings Supported branding, language, authentication, asset and map settings
Extension settings Declared stored values for selected extension subjects, without copying secret values
Translations Custom translation strings grouped by language

The manifest selects which resource kinds the tree manages. An omitted kind is left alone. Within a managed kind, omission can mean deletion. Read Managed scope and deletions before reducing a tree or applying it to an existing project.

Snapshots do not transfer collection items, user accounts, uploaded file data, file records, or extension packages. Use Backups or Migration between instances when moving a complete deployment.

Run these commands with the local instance’s database configuration loaded:

Terminal window
cairncms config snapshot ./config
cairncms config apply ./config --dry-run

The first command captures the instance. The second compares the tree with that instance without changing it. An unchanged capture reports No changes to apply.

Back up the target before applying changes.

Follow Your first apply for a disposable walkthrough, or Deploying across environments for the promotion workflow.

Surface Input Target
Local CLI Directory of YAML files Database configured for the CLI process
Remote CLI The same directory Instance selected by --url, using an administrator token
HTTP API One complete JSON or YAML document Server receiving the request