Skip to content

secret

kind: secret
name: github
spec:
encrypted: |
-----BEGIN AGE ENCRYPTED FILE-----
...
-----END AGE ENCRYPTED FILE-----
---
kind: process
name: server
spec:
cmd: ./server
env:
GITHUB_TOKEN: ${ secret.github }

The daemon resolves the value, keeps it in memory and publishes a placeholder, which a process’s env or a file resource’s content turns back into the value. The Secrets page explains the model: the placeholder, where the value goes and where it never does, and the ways to use a secret.

Give exactly one source:

field
encrypted an armored age file encrypted to the workspace’s recipients, decrypted with this machine’s key. Write it with runy secret set
command a shell command run with sh -c in the workspace root; its stdout, without one trailing newline, is the value. It may run for 30 seconds, and its stderr goes to the secret’s journal
file a file whose contents, without one trailing newline, are the value (a source to read, unrelated to the file kind, which writes one); relative to the workspace root, ~ for your home folder
env a variable of the daemon’s environment

And optionally inject, which serves the secret on the gateway and lets a machine use it as a credential:

field default
hosts the host names the value is for, no scheme, port or path. The gateway forwards to the first required
header the request header the value goes in Authorization
value the header’s value, {value} standing for the secret Bearer {value}
kind: secret
name: db
spec:
command: pass show dev/db
---
kind: secret
name: anthropic
spec:
file: ~/.config/anthropic/key
inject:
hosts: [api.anthropic.com]
header: x-api-key
value: "{value}"

A value is UTF-8 text and must not be empty. A trailing \n or \r\n is dropped once from a command’s output and from a file. A change of inject is a new revision, like a new value.

A secret’s name and namespace are ASCII letters, digits, ., _ and -. With inject they must also be DNS labels (lowercase letters, digits and -), since the gateway’s host name is built from them. A name outside these rules is an Error.

In an expression a hyphenated name needs brackets, see Scope. The gateway’s host name keeps the hyphen: github-token.secret.runy.localhost.

{
"value": "runy-secret:_/anthropic:3f9a0c1e",
"source": "file",
"revision": "3f9a0c1e",
"url": "http://anthropic.secret.runy.localhost"
}
field
value the placeholder runy-secret:<namespace>/<name>:<revision>, never the value. ${ secret.<name> } reads it, the secret’s default value
source the spec key the value came from, or hub in a machine whose host handed it the value (see Secrets in machines)
revision eight hex digits of a keyed HMAC of the value and, with inject, of its hosts, header and value format
url the gateway’s URL, published as soon as the spec has inject. In a machine, a secret with source: hub leaves the name to the host’s gateway (see Secrets in machines)

There is no status (or only url) while the value is not resolved, and the readers of the value wait. url does not depend on the value, so a reader of ${ secret.<name>.status.url } does not wait.

The revision key is kept in secrets.revision in the state folder, so the same value renders the same placeholder after a restart or an upgrade.

The value is resolved when the resource starts, when its spec changes and on the restart signal. Until then every resource that reads the value stays Pending. A failed resolution forgets the value the secret had and is the secret’s Error, with condition key Secret; its readers keep waiting. runy secret ls shows the state as resolved <revision>, resolving, pending, error: ..., idle, disabled or unknown.

message cause
set exactly one of encrypted, command, fileandenv`` none or more than one source
a secret's name and namespace are ASCII letters, digits, ., _and-`` a name outside the naming rule
`x` is not a host name (no scheme, port or path) an inject.hosts entry that is not a bare host
`x` is not a header name an invalid inject.header
`value` must contain `{value}` an inject.value without the token
`<script>` did not finish within 30s a command that ran too long
the daemon's environment has no `X` an env source naming a variable the daemon lacks
the value from ... is empty, ... is not UTF-8 text a value that is empty or not text
not a recipient: add age1…to the workspace's recipients and runruny secret rekey where the value can be read the value was not encrypted to this machine’s key, see Secrets for a team
this machine cannot decrypt the value (...), and ... in a machine: the host did not hand the value over, see Secrets in machines

A gateway name that a domains entry, the API or another secret already holds is an Error naming the holder.

signal
restart resolves the value again, which picks up a changed file or command output: runy signal secret/github restart

After a daemon upgrade the secret resolves its value again, and a process that ran through the upgrade keeps running.