Overview
Thecerbos run command launches a command within the context of a Cerbos Policy Decision Point (PDP). This is useful for running tests or applications that need to interact with Cerbos without managing a separate server process.
The command automatically:
- Starts a Cerbos PDP server
- Waits for it to be ready
- Sets environment variables with Cerbos endpoints
- Runs your command
- Cleans up when your command exits
Usage
-- separator between Cerbos flags and the command to run.
Arguments
The command to run in the Cerbos context. All arguments after
-- are passed to this command.Flags
Configuration
Path to the Cerbos configuration file.If not specified and a
.cerbos.yaml file exists in the current directory, it will be used automatically.If no configuration file is found, a default configuration is used with policies loaded from a policies directory in the current working directory.Override configuration values. Can be specified multiple times.Format:
key=value (supports nested keys using dot notation)Example: --set=server.adminAPI.enabled=trueLogging
Set the log level for the Cerbos PDP.Options:
debug, info, warn, errorUse error to silence most Cerbos output.Startup
Maximum time to wait for the Cerbos PDP to start and be ready.Format: Duration string (e.g.,
30s, 1m, 500ms)Environment Variables
When your command runs, the following environment variables are automatically set:CERBOS_HTTP- HTTP endpoint address (e.g.,http://127.0.0.1:3592)CERBOS_GRPC- gRPC endpoint address (e.g.,127.0.0.1:3593)
Default Configuration
If no configuration file is specified or found,cerbos run uses this default configuration:
policies directory is created automatically if it doesn’t exist.
Examples
Run Go tests with Cerbos
Run Python tests with Cerbos
Run with a custom configuration file
Silence Cerbos log output
Run with configuration overrides
Use with npm/node tests
Increase startup timeout
Run with debug logging
Exit Codes
Thecerbos run command exits with:
- The exit code of your command if it runs successfully
- A non-zero exit code if the Cerbos PDP fails to start
- A non-zero exit code if your command fails to execute
Use Cases
Local Development
Run your application locally with an embedded Cerbos instance:Integration Testing
Run integration tests that require Cerbos:CI/CD Pipelines
Use in CI to test against Cerbos without managing a separate service:Quick Verification
Quickly verify Cerbos is working:Policy Directory Structure
By default,cerbos run looks for policies in a policies directory. Organize your policies like this: