Docs

Vault

A Vault is a store for the secrets your software creates or changes while it runs, such as tokens from an integration or keys it rotates, in the cloud's own secret service. The values stay in the customer's environment, encrypted by the cloud provider, and the customer can audit access with their own tools.

alien.ts
import * as alien from "@alienplatform/core"

const credentials = new alien.Vault("credentials").build()

const api = new alien.Worker("api")
  .code({ type: "source", src: "./api", toolchain: { type: "typescript" } })
  .link(credentials)
  .permissions("execution")
  .build()

export default new alien.Stack("acme")
  .add(credentials, "frozen")
  .add(api, "live")
  .permissions({
    profiles: { execution: { credentials: ["vault/data-read", "vault/data-write"] } },
  })
  .build()

In this stack:

  • .link(credentials) connects the vault to the api Worker, the workload (the running code) that uses it. Alien injects the vault's connection details, its binding, into the Worker, read by the SDK client.
  • The execution permission profile, the named set of cloud permissions a workload runs with, grants vault/data-read and vault/data-write.
  • "frozen" means the customer's admin creates the vault during initial setup. "live" resources, like the Worker, are created and updated by Alien on every release. See Frozen and live.

The api Worker writes and reads secrets at runtime:

api/src/credentials.ts
import { vault } from "@alienplatform/sdk"

const credentials = vault("credentials")
await credentials.putJson("github", { token: "ghp_example" })
const github = await credentials.getJson<{ token: string }>("github")

Platforms

credentials becomes secrets in the environment's native secret service:

PlatformBacking serviceCreated by
AWSSSM Parameter Store SecureString parameters named <prefix>-<secret>Nothing to create. The vault is a name prefix.
GCPSecret Manager secrets named <prefix>-<secret>, automatic replicationNothing to create. The vault is a name prefix.
AzureOne Key Vault per Vault resource, Standard SKU, Azure RBACAlien
KubernetesKubernetes Secrets in the deployment's namespaceNothing to create. Secrets are created on first write.
MachinesA vault the customer providesThe customer, through an external binding. The resource must be "frozen". See Machines.
Localvault/<id>/secrets.json in the local state directory, not encryptedAlien

<prefix> is the stack's resource prefix followed by the Vault's ID.

Frozen or live

Vault can be "frozen" (created once during initial setup by the customer's admin) or "live" (created and updated by Alien on releases). See Frozen and live.

The ID may contain letters, digits, -, and _. On Azure it becomes part of a Key Vault name, which limits the ID to 15 characters.

Alien reserves two IDs for its own vaults. Don't declare a Vault with either:

  • secrets holds environment secrets.
  • deployer-secrets holds secrets the deployer (the person who runs the initial setup, usually the customer's admin) writes with their own credentials.

Alternatives

Vault is for secrets your code writes at runtime. For secrets the deployer enters during initial setup, or that you set per deployment, use stack inputs and environment secrets:

Inputs and environment secretsVault
Set byThe deployer at initial setup, or you per deploymentYour code at runtime
Read byEnvironment variablesSDK calls
Changes take effectOn the next deploymentOn the next get

Use KV for non-secret state, and Key to encrypt data with a customer-managed key.

Options

MethodTypeDefaultNotes
.enabled(input)boolean stack inputalways onCreates the resource only when the input is true.

The backing service follows the platform. There are no other options.

Use it from code

src/credentials.ts
import { vault } from "@alienplatform/sdk"

const credentials = vault("credentials")

await credentials.putJson("github", { token: "ghp_example" })
const github = await credentials.getJson<{ token: string }>("github")
await credentials.delete("github")

Every method is in the API reference.

Common patterns

Name secrets so they work everywhere

Use lowercase letters, digits, and hyphens, such as github-token. Azure turns _ into - and Kubernetes lowercases names, so API_KEY and api-key can end up as the same secret.

Keep values under 4 KB, the smallest limit across platforms. See Behavior and limits.

Store structured secrets

putJson and getJson (TypeScript) serialize to and from a JSON string, so you can keep related values, such as a client ID and secret, under one name. In Python and Rust, serialize with json or serde_json.

Cache reads

Every get is a call to the cloud's secret service, and some services throttle reads. Read a secret once at startup, or cache it for a few minutes, instead of reading it on every request.

Keep a list of names yourself

list() works only on Kubernetes and Local. On AWS, GCP, and Azure it fails with OPERATION_NOT_SUPPORTED.

To enumerate secrets, store the names you've written in a KV entry or a separate secret.

Management access

By default, only workloads you grant can read or write a Vault you declare. Alien's management identity, which runs remote bindings for your hosted software, can't.

To let your hosted software write secrets into a customer's vault, for example after an OAuth flow, extend management permissions:

alien.ts
export default new alien.Stack("acme")
  .add(credentials, "frozen")
  .permissions({
    profiles: { execution: { credentials: ["vault/data-read"] } },
    management: { extend: { credentials: ["vault/data-write"] } },
  })
  .build()

vault/data-write creates, updates, and deletes secrets but can't read values back. Grant vault/data-read to management only if your hosted software must read secret values.

Permissions

SetGrants
vault/data-readReading secret values.
vault/data-writeCreating, updating, and deleting secrets, without reading values.
vault/certificate-managementManaging application TLS certificates in the shared vault.
vault/provision, vault/management, vault/heartbeatUsed by initial setup and by Alien's management identity.

Linking a Vault to a workload with no permission set named for it grants vault/data-read and vault/data-write. See Permissions.

Next

On this page