Skip to content

DigitalOcean.Security reference

Source: packages/digitalocean/src/Security/ReadSecret.ts

Read a secret’s values from a runtime. The values reach the host as secrets in its environment when it deploys, so a runtime holds no DigitalOcean token: DigitalOcean signs no workload identity a runtime could exchange for one. Changing the secret’s values redeploys the runtimes bound to it.

const Stripe = DigitalOcean.Security.Secret("stripe", {
values: { STRIPE_KEY: "sk_test_..." },
});
export default class Api extends DigitalOcean.App<Api>()(
"Api",
{ main: import.meta.url },
Effect.gen(function* () {
const secret = yield* Stripe;
const stripe = yield* DigitalOcean.Security.ReadSecret(secret);
return {
fetch: Effect.gen(function* () {
const key = yield* stripe.get("STRIPE_KEY");
return HttpServerResponse.text(Redacted.value(key).slice(0, 7));
}).pipe(Effect.orDie),
};
}).pipe(Effect.provide(DigitalOcean.Security.ReadSecretHttp)),
) {}

Source: packages/digitalocean/src/Security/ReadSecretHttp.ts Kind: Layer · Provides: DigitalOcean.Security.ReadSecret

ReadSecret for any host: the values travel as one secret through the host’s runtime context.

Source: packages/digitalocean/src/Security/Secret.ts

A DigitalOcean secret: versioned key-value pairs stored encrypted in one region. Bind it to a runtime with ReadSecret. Changing values writes a new version in place; name and region replace the secret.

Deleting a secret leaves it pending deletion for a while, and its name stays taken. A deploy that declares a secret pending deletion restores it instead of failing.

const key = yield* Config.Redacted("STRIPE_KEY");
const stripe = yield* DigitalOcean.Security.Secret("stripe", {
region: "nyc3",
values: { STRIPE_KEY: key },
});