Overview
Theput command uploads policies and schemas to a Cerbos server. It supports uploading individual files, multiple files, entire directories, and ZIP archives.
Syntax
Subcommands
Put Policies
Upload policy files to the Cerbos server. Aliases:policy, policies, p
Examples
Upload policies from directories
Put Schemas
Upload JSON schema files to the Cerbos server. Aliases:schema, schemas, s
Examples
Flags
| Flag | Short | Description |
|---|---|---|
--recursive | -R | Process the directory used in paths recursively |
Understanding the Output
When you upload files, cerbosctl provides a summary of the operation:- Uploaded: Number of files successfully uploaded to the server
- Ignored: Number of files that were skipped due to errors
- Errors: Detailed list of files that failed and the reasons why
File Types
Policy Files
Cerbosctl recognizes policy files with the following extensions:.yaml.yml
Schema Files
Cerbosctl recognizes schema files with the following extension:.json
Common Patterns
Organize Policies in Directories
Organize your policies by type for easier management:Upload Schemas for Validation
Deploy from CI/CD
Integrate cerbosctl into your CI/CD pipeline:Error Handling
Cerbosctl validates files before uploading. Common errors include:Missing Required Fields
Invalid Policy Format
Schema Validation Errors
Connection Errors
- The Cerbos server is running
- The
--serveraddress is correct - Admin API is enabled
- Authentication credentials are valid
Advanced Usage
Combining Multiple Operations
You can upload policies and schemas in sequence:Using with Environment Variables
Set up your environment once:Dry Run Alternative
While cerbosctl doesn’t have a built-in dry run, you can use theinspect command to validate policies locally before uploading:
Working with Mutable Stores
When using mutable policy stores (database-backed), theput command will:
- Create new policies if they don’t exist
- Update existing policies if they already exist (based on policy ID)
- Validate all policies before applying changes
resource.leave_request.default).
Best Practices
Version Control
Store your policies and schemas in version control (Git) to track changes over time.
Test Before Production
Test policy uploads in a development environment before deploying to production.
Use Recursive Flag Carefully
The
-R flag processes entire directory trees. Ensure only valid policy files are in the directory.Automate Deployments
Integrate cerbosctl into your CI/CD pipeline for automated policy deployments.
Monitor Upload Results
Always check the upload summary to ensure all files were processed successfully.