Vault API reference
The Vault API is the set of methods your code calls on a linked Vault, in the TypeScript, Python, and Rust SDKs. A binding is the connection details Alien injects into each workload linked to the resource, which the SDK client reads.
A handle comes from these calls, where name is the resource ID from alien.ts:
- TypeScript:
vault(name)from@alienplatform/sdk - Python:
vault(name)fromalienplatform - Rust:
Bindings::from_env()?.vault(name).await?fromalien-sdk
Creating the handle in TypeScript or Python does no I/O. The binding resolves on the first call and is cached. Secret values aren't cached: every get reads from the secret service.
Methods at a glance
| TypeScript | Python | Rust | What it does |
|---|---|---|---|
get, getJson | get(name) | get_secret(name) | Read a secret. |
put, putJson | put(name, value) | set_secret(name, value) | Create or overwrite a secret. |
delete | delete(name) | delete_secret(name) | Delete a secret. |
list | list() | list_secrets() | List secret names. Kubernetes and Local only. |
create_secret(name, value) | Create a secret only if it doesn't exist. | ||
secret_presence(name) | Check a secret without reading its value. |
Secret names are passed to the backing service as they are, apart from the platform rewrites in Behavior and limits. Values are strings.
get
Reads the current value of a secret. Throws VAULT_SECRET_NOT_FOUND when it doesn't exist.
const token = await credentials.get("github-token") // string
const github = await credentials.getJson<{ token: string }>("github") // parsed JSONgetJson throws a SyntaxError if the value isn't valid JSON.
On GCP, get reads the latest version. On Azure, it reads the newest version.
put
Creates the secret if it doesn't exist and overwrites it if it does.
await credentials.put("github-token", "ghp_example")
await credentials.putJson("github", { token: "ghp_example", scopes: ["repo"] }) // JSON.stringifyHow each platform stores an overwrite:
| Platform | Overwrite |
|---|---|
| AWS | A new parameter version (Overwrite: true). |
| GCP | A new secret version. Older versions stay enabled and are billed. |
| Azure | A new secret version. |
| Kubernetes | The Secret is replaced. |
| Local | The file is rewritten. |
delete
Deletes a secret. Deleting a secret that doesn't exist succeeds.
await credentials.delete("github-token")On GCP, delete removes the secret and all its versions.
On Azure, the secret goes into Key Vault's soft-deleted state and keeps its name. A put with the same name fails until the retention period ends. See Behavior and limits.
list
Returns the names of the secrets in this vault, without the vault's prefix, so each name can be passed back to get.
const names: string[] = await credentials.list()| Platform | Supported |
|---|---|
| Kubernetes | Yes. Returns the stored names, which are lowercased and use - for _. |
| Local | Yes. |
| AWS, GCP, Azure | No. Fails with OPERATION_NOT_SUPPORTED. |
Why not on the clouds:
- AWS: parameter names are flat (
<prefix>-<secret>), so a prefix search for vaultappwould also return secrets from a vault namedapp-prod. Listing is disabled rather than mixing vaults. - GCP and Azure: the client doesn't implement listing yet.
create_secret
Rust only. Creates a secret only if no secret with that name exists. If one does, the write is skipped and the call fails with VAULT_SECRET_ALREADY_EXISTS.
use alien_sdk::ErrorData;
match credentials.create_secret("signing-key", &generated).await {
Ok(()) => {}
Err(e) if matches!(e.error, Some(ErrorData::VaultSecretAlreadyExists { .. })) => {}
Err(e) => return Err(e.into()),
}| Platform | How it's conditional |
|---|---|
| AWS | PutParameter with Overwrite: false. Atomic. |
| Azure | Lists the secret's versions, then writes if there are none. Not atomic, so use it only when one writer owns the secret. A soft-deleted secret counts as existing. |
| Kubernetes | Creates the Secret, which the API server refuses if it exists. Atomic. |
| Local | Checks the file, then writes. |
| GCP | Not supported. Fails with OPERATION_NOT_SUPPORTED. |
secret_presence
Rust only. Reports whether a secret exists and is usable, from metadata only. The value is never fetched.
use alien_bindings::SecretPresence; // not re-exported from alien-sdk
match credentials.secret_presence("github-token").await? {
SecretPresence::Present { version } => { /* version changes on every overwrite */ }
SecretPresence::Missing => { /* never written */ }
SecretPresence::Invalid { reason } => { /* exists but can't be used as is */ }
}version is the store's own identifier for the current value: an SSM parameter version, a Secret Manager version name, a Key Vault version ID, a Kubernetes resourceVersion, or a local write counter.
Compare it to decide when to restart a workload to pick up a new value.
Invalid covers cases such as an SSM parameter that isn't a SecureString, a disabled or destroyed latest version on GCP, or a disabled or expired version on Azure.
The binding
A linked Vault injects ALIEN_<NAME>_BINDING, uppercased with hyphens as underscores: credentials becomes ALIEN_CREDENTIALS_BINDING. The SDKs read it for you. It's JSON tagged by service:
service | Platform | Fields |
|---|---|---|
parameter-store | AWS | vaultPrefix |
secret-manager | GCP | vaultPrefix |
key-vault | Azure | vaultName |
kubernetes-secret | Kubernetes | namespace, vaultPrefix |
local-vault | Local | vaultName, dataDir |
The binding holds no secret values and no credentials. The workload's own identity authorizes each call.
Errors
| Code | Retryable | When |
|---|---|---|
VAULT_SECRET_NOT_FOUND | No | get on a secret that doesn't exist. |
VAULT_SECRET_ALREADY_EXISTS | No | create_secret on a secret that exists. |
OPERATION_NOT_SUPPORTED | No | list on AWS, GCP, or Azure, or create_secret on GCP. |
CLOUD_PLATFORM_ERROR | Yes | Any other failure from the secret service, including access denied and throttling. The cause is attached. |
BINDING_NOT_CONFIGURED | No | The workload isn't linked to this resource. |
Errors name the secret, never its value.