Skip to content

WriteSecret

Source: src/Fly/WriteSecret.ts

Create, update, and delete Fly.io App secrets at runtime.

The App is fixed by WriteSecret(secret). Calls take no app_name. Inside a Machine or Service, Alchemy mints an App deploy token. Inside an Action, the ambient FLY_API_TOKEN is used.

Bind the client in init. Provide WriteSecretHttp. Wrap values with Redacted.make.

const Seed = Alchemy.Action(
"Seed",
Effect.gen(function* () {
const secrets = yield* Fly.WriteSecret(ApiToken);
return Effect.fn(function* () {
yield* secrets.create("API_KEY", Redacted.make("sk_live"));
});
}).pipe(Effect.provide(Fly.WriteSecretHttp)),
);

update rotates by name (batch of one).

yield* secrets.update("API_KEY", Redacted.make("sk_live_rotated"));

delete removes a secret by name.

yield* secrets.delete("API_KEY");