Policy stores: CLI upload (Container)
The cerbosctl
CLI tool is also available as a Docker container image:
docker run --rm -it ghcr.io/cerbos/cerbosctl:latest hub store
docker run --rm -it docker.io/cerbos/cerbosctl:latest hub store
Usage
The cerbosctl
container can be used to upload policies to a policy store in Cerbos Hub.
First generate a set of client credentials for the policy store in Cerbos Hub - you can do this in the Client credentials section in the UI. Make sure to select the Read & Write
option when creating the credentials to allow uploading policies.
Then export the following environment variables with the values from the generated client credentials and the store ID:
export CERBOS_HUB_CLIENT_ID=...
export CERBOS_HUB_CLIENT_SECRET=...
export CERBOS_HUB_STORE_ID=...
The following command uploads policy files from the policies directory and replaces all the files in the store.
docker run -it {cerbosctl-docker-img} \
-e CERBOS_HUB_CLIENT_ID=$CERBOS_HUB_CLIENT_ID \
-e CERBOS_HUB_CLIENT_SECRET=$CERBOS_HUB_CLIENT_SECRET \
-e CERBOS_HUB_STORE_ID=$CERBOS_HUB_STORE_ID \
-v $(pwd):/policies \
hub store replace-files /policies .
Full CLI Reference
Usage: cerbosctl hub store --store-id=STRING --client-id=STRING --client-secret=STRING <command> [flags]
Interact with Cerbos Hub managed stores.
Requires an existing managed store and the API credentials to access it. The store ID and credentials can be provided using either command-line flags or
environment variables.
Flags:
-h, --help Show context-sensitive help.
--store-id=STRING ID of the store to operate on ($CERBOS_HUB_STORE_ID)
--client-id=STRING Client ID of the access credential ($CERBOS_HUB_CLIENT_ID)
--client-secret=STRING Client secret of the access credential ($CERBOS_HUB_CLIENT_SECRET)
Commands:
hub store list-files --store-id=STRING --client-id=STRING --client-secret=STRING [flags]
List store files
hub store get-files --store-id=STRING --client-id=STRING --client-secret=STRING --output-path=STRING <files> ... [flags]
Download files from the store
hub store download --store-id=STRING --client-id=STRING --client-secret=STRING <output-path> [flags]
Download the entire store
hub store replace-files --store-id=STRING --client-id=STRING --client-secret=STRING <path> [flags]
Overwrite the store with the given set of files
hub store add-files --store-id=STRING --client-id=STRING --client-secret=STRING <paths> ... [flags]
Add files to the store
hub store delete-files --store-id=STRING --client-id=STRING --client-secret=STRING <paths> ... [flags]
Delete files from the store