Secrets & Environment
Jobs and Servers accept ordinary environment variables and named secret bundles. Use environment values for non-sensitive, deployment-specific configuration. Use Secrets for reusable API keys, tokens, and passwords whose values should not appear in API responses.
| Environment values | Secrets | |
|---|---|---|
| Visible in API responses | Yes | Never |
| Reusable by name | No | Yes |
| Rotation | Resubmit with new values | Update bundle, then resubmit |
Pass environment variables
# Explicit value
anycloud submit ghcr.io/acme/train:latest -e MODE=eval
# Read a value from the current shell
anycloud submit ghcr.io/acme/train:latest -e DATASET_TOKEN
# Load a file; explicit -e flags win
anycloud submit ghcr.io/acme/train:latest \
--env-file .env \
-e MODE=eval
Python accepts a dictionary:
job = ac.submit(
"ghcr.io/acme/train:latest",
env={"MODE": "eval", "RUN_NAME": "baseline"},
)
The CLI warns when a likely-sensitive key is passed through --env, but the
submission proceeds.
Create a Secret
Each Secret is a named bundle of one or more KEY=VALUE pairs:
anycloud secrets new hugging-face HF_TOKEN=hf_xxxxxxxxxxxx
anycloud secrets new tracking \
WANDB_API_KEY=xxxxx \
WANDB_ENTITY=my-team
The list command returns names and timestamps, never values:
anycloud secrets list
Inject Secrets
- CLI
- Python
anycloud submit ghcr.io/acme/train:latest \
--gpu-type h100 \
--secret hugging-face \
--secret tracking
import anycloud
ac = anycloud.Client()
ac.create_secret("hugging-face", {"HF_TOKEN": "hf_xxxxxxxxxxxx"})
job = ac.submit(
"ghcr.io/acme/train:latest",
gpu="h100",
secrets=["hugging-face", "tracking"],
)
Secrets also work with @anycloud.function(), @anycloud.serve(), and
Servers started from the CLI.
Precedence and rotation
An explicit environment value wins over a same-named key from a Secret. That supports a one-off override without editing the saved bundle.
Overwrite a bundle and resubmit to rotate it:
anycloud secrets new hugging-face HF_TOKEN=hf_rotated
anycloud resubmit <job-id>
Running containers retain the values injected when their VM started. A new submit, resubmit, or spot replacement reads the current bundle.
Deletion is blocked while a non-terminal deployment references the Secret.
--force bypasses that safeguard, but the next VM start for a deployment that
still references the missing name will fail.
anycloud secrets delete hugging-face --force
Storage and threat model
Secret values are encrypted in the local Anycloud database with libsodium (XSalsa20-Poly1305). The API offers create, list, and delete operations but no operation that returns a value.
At provisioning time, resolved values are written to
/run/anycloud-secrets.env on tmpfs with mode 0600, then supplied to Docker
through --env-file.
Docker inlines environment values into the container's run configuration.
Anyone with root access on the VM can read them through docker inspect or a
process environment. Secrets protect values from plaintext local storage and
the Anycloud API response surface; they are not a defense against a VM-root
attacker.
See secrets reference for exact command syntax.