Skip to main content

Stash

Alpha

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

The stash keeps small values about your infrastructure next to the project, environment, component, instance, or deployment they describe. People, the Massdriver UI, the CLI, automations, and later deployment steps can all read them.

Each project, environment, component, instance, and deployment has its own stash. A stash holds key and value entries, such as db/hostname = billing-dev.cluster-abc.us-east-1.rds.amazonaws.com or md/v1/health = {"state": "healthy"}. Massdriver keeps an entry until you delete it or until it expires.

Who writes to the stash​

WriterHow it signs inExample
A provisioner during a deploymentThe deployment's token. Massdriver sets it in every step. Use mass alpha stash or the Terraform provider.A Terraform step records the database host for a later step.
A CI job or a scriptA service account's access token, with mass alpha stash, the Terraform provider, or the GraphQL APIA release job records the version that it deployed.
An automationA service account's access tokenThe stash-sync automation copies CloudWatch and Prometheus metrics into widget keys.
A personYour own login, with the CLI or the APIYou set a maintenance banner on an environment.

Who reads the stash​

ReaderWhat it reads
The Metadata panels in the UIEntries that have a label. See Metadata.
Automatic widgets in the UIWell-known md/v1/ keys. See Well-known keys.
Notes and widgets that you pinAny key that you choose. See Annotations.
Later deployment stepsAny entry in the stashes that the deployment's token can read
Event destinationsstash_entry.set and stash_entry.deleted events. See Events.
Other automations and scriptsAny entry that their service account can read

Use cases​

Pass a value between deployment steps​

One step writes a value to the deployment's stash. A later step reads it.

shell
mass alpha stash set "$MASSDRIVER_DEPLOYMENT_ID.db/hostname" "$DB_HOST"
DB_HOST=$(mass alpha stash get "$MASSDRIVER_DEPLOYMENT_ID.db/hostname")

In Terraform, the massdriver_stash_entry resource writes an entry, and the massdriver_stash_entry data source reads one.

Record what a deployment did​

Write the result of each step to a well-known deployment result key. The deployment's details show a Results section, and the instance's Signals tab shows the latest results.

shell
mass alpha stash set "$MASSDRIVER_DEPLOYMENT_ID.md/v1/changes/$MASSDRIVER_STEP_PATH" \
'{"tool": "opentofu", "add": 2, "change": 3, "destroy": 0}' --format json
mass alpha stash set "$MASSDRIVER_DEPLOYMENT_ID.md/v1/cost_estimate" \
'{"tool": "infracost", "currency": "USD", "monthly_before": 41.20, "monthly_after": 41.58}' --format json

Show live health, usage, and traffic on the canvas​

Write md/v1/health, md/v1/usage, or md/v1/traffic on an instance. A status dot, a usage bar, or traffic on its lines shows on the canvas for everyone with stash:view. Set a TTL so that the widget goes away when the writer stops.

shell
mass alpha stash set billing-dev-app.md/v1/health '{"state": "degraded"}' --format json --ttl 600
mass alpha stash set billing-dev-app.md/v1/traffic '{"rps": 240, "errors_5m": 2, "p95_ms": 180}' --format json --ttl 600

Write md/v1/links on the environment. Each link is a button in the environment header.

shell
mass alpha stash set billing-dev.md/v1/links \
'{"links": [{"label": "Runbook", "url": "https://wiki.example.com/billing"}, {"label": "Shop", "url": "https://shop.example.com"}]}' \
--format json

Show a banner for a maintenance window​

Write md/v1/banner on the environment with a TTL that ends with the window. The banner goes away when the entry expires.

shell
mass alpha stash set billing-dev.md/v1/banner \
'{"message": "Database upgrade from 22:00 to 23:00 UTC", "level": "warning"}' \
--format json --ttl 7200

Mark a one-time task as done​

An immutable entry cannot be set again until it expires or is deleted. The write fails when the key already has a value, so a step can use it to run only once.

shell
if mass alpha stash set "$MASSDRIVER_DEPLOYMENT_ID.migrations/ran" true --immutable; then
./run-migrations.sh
fi

Keep a value for a set time​

Set a TTL in seconds. The entry is deleted when the time ends. Compute the value again when it is missing.

shell
AMI=$(mass alpha stash get billing-dev-app.ami-id) || {
AMI=$(./find-latest-ami.sh)
mass alpha stash set billing-dev-app.ami-id "$AMI" --ttl 86400
}

Keep a secret that a later step needs​

A sensitive entry is encrypted with your organization's key. Only callers with stash:export, and deployment tokens that can write the stash, can read the value. It never shows in events, notes, or widgets.

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

How it works​

  • Stashes do not inherit. A key on an environment is not visible from the stash of its instances or deployments. To read it, read the environment's stash.
  • A set replaces the whole entry. The value, format, label, TTL, and flags all come from the new write. A setting that you leave out goes back to its default.
  • Well-known keys. Keys that start with md/ are reserved. The server checks each md/ write against the key's schema. See Well-known keys.

Entries​

FieldRules
KeyLetters, digits, and the characters _, ., /, and -. Up to 255 characters.
ValueAlways a string. Massdriver returns it exactly as written. It cannot contain the null character.
FormatTEXT (the default) or JSON. A JSON value must be a JSON object. The API also returns a JSON value parsed, in the data field.
LabelOptional. A name for the entry, up to 255 characters. An entry with a label shows as a row on the Metadata panels. A label is not encrypted.
TTLOptional. Seconds until the entry expires, up to 315360000 (10 years). An expired entry is not returned, and is deleted within 10 minutes. Without a TTL, the entry stays until you delete it.
ImmutableOptional. When true, the key cannot be set again until the entry expires or is deleted. You can delete it. An immutable write fails when the key already has a value.
SensitiveOptional. When true, the value is encrypted with your organization's key and masked for callers without stash:export. It is never sent in events and never available to notes or widgets. A well-known md/ key cannot be sensitive.

Limits​

LimitDefaultSetting for self-hosted installations
Value size65536 bytesMD_STASH_MAX_VALUE_BYTES
Keys in one stash1000MD_STASH_MAX_KEYS_PER_SCOPE

Expired entries do not count toward the key limit.

Permissions​

The stash has its own access control actions.

ActionLets you
stash:viewRead entries, without sensitive values, and subscribe to their changes
stash:writeSet and delete entries
stash:exportRead sensitive values

Each action is checked against the entity that holds the entries: the project, environment, component, or instance. A deployment's entries belong to its instance. Conditions on that entity's attributes apply. stash:view does not come with project:view. Grant it on its own.

A deployment's own credentials do not use these actions. A deployment can read and write the stash of that deployment and of its instance, environment, component, and project. It can also read, but not change, the stash of each instance whose resources its instance uses as dependencies, without their sensitive values.

Events​

Each set and delete sends an event. An entry that expires sends no event. A key that Massdriver sets itself, such as a UI notice, sends only the alphaStashEvents event.

  • The projectEvents, environmentEvents, instanceEvents, and deploymentEvents subscriptions send an AlphaStashEntryEvent. Which subscriptions get it depends on the entity that holds the entry.
  • The audit log and event destinations get stash_entry.set and stash_entry.deleted events.
  • A sensitive entry never includes its value in an event.
StashSubscriptions
ProjectprojectEvents
EnvironmentprojectEvents, environmentEvents
ComponentprojectEvents
InstanceenvironmentEvents, instanceEvents
DeploymentenvironmentEvents, instanceEvents, deploymentEvents

The alphaStashEvents subscription also sends sets and deletes for a project and one environment.

Where stash values show​

PlaceWhat shows
The Signals tab of an instanceThe instance's widgets, its latest deployment results, its scorecards, and its labeled entries
The deployment's detailsA Results section and a Deployment metadata section with the deployment's labeled entries
The Metadata card on the project overviewThe project's labeled entries
The canvas and the environment headerAutomatic widgets from md/v1/ keys, and widgets and notes that you pin
The notice bell in the app headerNotices when a project or environment is created, and when a deployment is proposed, approved, started, or finished

These places update when a stash value changes. You do not need to reload the page. An entry that expires does not send an update. The UI removes it when its time ends.

Next​