Skip to main content

Stash CLI

Alpha

This feature is alpha. Names, fields, and behavior can change or be removed at any time without notice.

The mass alpha stash commands need mass 2.7.0 or later.

CommandWhat it does
mass alpha stash get <scope>.<key>Prints the value
mass alpha stash set <scope>.<key> <value>Sets the value
mass alpha stash delete <scope>.<key>Deletes the entry. Alias: rm.
mass alpha stash list <scope>Lists the entries in one stash. Alias: ls.

Outside a deployment, the CLI signs in with your mass profile or with MASSDRIVER_API_KEY and MASSDRIVER_ORGANIZATION_ID. For a CI job or a script, use a service account's access token. See CLI configuration. In a deployment, see Inside a deployment.

Addresses​

An address is <scope>.<key>. The first . ends the scope, so a key can contain more dots. For example, in billing-dev-app.schema.version, the scope is billing-dev-app and the key is schema.version.

The scope is an identifier. Its shape tells the kind of entity:

ScopeKind
billingProject
billing-devEnvironment or component
billing-dev-appInstance
A UUIDDeployment

An environment and a component have the same shape. The CLI looks up both. When both exist, add a prefix to choose one: env:billing-app or component:billing-app. The prefixes project:, env:, environment:, component:, instance:, and deployment: are always accepted.

get​

Prints the value exactly as it is stored, with no trailing newline. The command fails when the key has no value or has expired. A sensitive value is printed only for callers who have stash:export on its stash, and for a deployment token that can write the stash. Other callers get an error.

shell
DB_HOST=$(mass alpha stash get "billing-dev-app.db/hostname")

With -o json, it prints the whole entry: the value, the label, the format, the flags, and the expiry.

shell
mass alpha stash get "billing-dev-app.stats" -o json | jq .data.changed

set​

shell
mass alpha stash set <scope>.<key> <value> [flags]
FlagMeaning
--formattext (the default) or json. A json value must be a JSON object.
--labelA name for the entry, up to 255 characters. It is not encrypted.
--ttlDelete the entry this many seconds after the write.
--immutableKeep the first value. Later writes fail.
--sensitiveEncrypt the value and hide it from callers without stash:export.

Each set replaces the whole entry, including the label, the format, the TTL, and the flags.

A value of - reads the value from standard input. Every byte is kept, including a trailing newline.

shell
terraform output -raw kubeconfig | mass alpha stash set "billing-dev.kubeconfig" - --sensitive

delete​

Asks you to type the key to confirm. Use --force (-f) in scripts to skip the question. Any other answer cancels the delete and exits with code 0.

shell
mass alpha stash delete "billing-dev-app.ami-id" --force

list​

Lists the entries in one stash. A sensitive value shows as (sensitive) unless you have stash:export. Use -o json for JSON output.

shell
mass alpha stash list billing-dev
mass alpha stash list "$MASSDRIVER_DEPLOYMENT_ID" -o json | jq -r '.[].key'

Inside a deployment​

In a provisioner, mass alpha stash signs in with the deployment's token (MASSDRIVER_DEPLOYMENT_ID and MASSDRIVER_TOKEN) when no API key is set. For what that token can read and write, see Permissions.

shell
mass alpha stash set "$MASSDRIVER_DEPLOYMENT_ID.db/hostname" "$DB_HOST" --label "Database hostname"