docs
evals
scenario-1
scenario-10
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
Manage short-lived secret tokens via an inline resource provider without shipping a separate plugin. Each instance persists its state to a file and surfaces the stored values as deferred outputs. State files are JSON documents that include the token, ttlSeconds, metadata, version, and lastRotated fields so lifecycle operations can round-trip values accurately.
stateDir/identifier.json), generates a random 32-byte token encoded in base64, sets version to 1, and records an ISO lastRotated timestamp; the exposed outputs mirror what is on disk. @testttlSeconds or metadata updates the existing file in place, keeps the id and token stable, increments version, refreshes lastRotated, and persists the new values. @testidentifier forces a replacement: a new file is created with a freshly generated token, version resets to 1, and the old file is removed so no orphaned state remains. @testexport type AsyncValue<T> = T | Promise<T>;
export interface TokenResourceArgs {
/** Directory where token files are persisted. */
stateDir: string;
/** Logical name used to derive the on-disk filename; changing this should trigger a replacement. */
identifier: string;
/** Time-to-live in seconds. */
ttlSeconds: number;
/** Optional metadata to persist alongside the token. */
metadata?: Record<string, string>;
}
export interface TokenResourceResult {
id: AsyncValue<string>;
token: AsyncValue<string>;
ttlSeconds: AsyncValue<number>;
metadata: AsyncValue<Record<string, string>>;
version: AsyncValue<number>;
lastRotated: AsyncValue<string>;
}
/**
* Infrastructure resource that stores and rotates a token using an inline provider.
*/
export class TokenResource {
constructor(name: string, args: TokenResourceArgs);
readonly id: AsyncValue<string>;
readonly token: AsyncValue<string>;
readonly ttlSeconds: AsyncValue<number>;
readonly metadata: AsyncValue<Record<string, string>>;
readonly version: AsyncValue<number>;
readonly lastRotated: AsyncValue<string>;
}Provides inline resource provider support for CRUD and diff lifecycles without requiring an external plugin.