import { ConfigMap, ConfigValue } from "./config"; import { EngineEvent } from "./events"; import { Deployment, PulumiFn, Workspace } from "./workspace"; /** * Stack is an isolated, independently configurable instance of a Pulumi program. * Stack exposes methods for the full pulumi lifecycle (up/preview/refresh/destroy), as well as managing configuration. * Multiple Stacks are commonly used to denote different phases of development * (such as development, staging and production) or feature branches (such as feature-x-dev, jane-feature-x-dev). * * @alpha */ export declare class Stack { /** * The name identifying the Stack. */ readonly name: string; /** * The Workspace the Stack was created from. */ readonly workspace: Workspace; private ready; /** * Creates a new stack using the given workspace, and stack name. * It fails if a stack with that name already exists * * @param name The name identifying the Stack. * @param workspace The Workspace the Stack was created from. */ static create(name: string, workspace: Workspace): Promise; /** * Selects stack using the given workspace, and stack name. * It returns an error if the given Stack does not exist. * * @param name The name identifying the Stack. * @param workspace The Workspace the Stack was created from. */ static select(name: string, workspace: Workspace): Promise; /** * Tries to create a new stack using the given workspace and * stack name if the stack does not already exist, * or falls back to selecting the existing stack. If the stack does not exist, * it will be created and selected. * * @param name The name identifying the Stack. * @param workspace The Workspace the Stack was created from. */ static createOrSelect(name: string, workspace: Workspace): Promise; private constructor(); private readLines; /** * Creates or updates the resources in a stack by executing the program in the Workspace. * https://www.pulumi.com/docs/reference/cli/pulumi_up/ * * @param opts Options to customize the behavior of the update. */ up(opts?: UpOptions): Promise; /** * Performs a dry-run update to a stack, returning pending changes. * https://www.pulumi.com/docs/reference/cli/pulumi_preview/ * * @param opts Options to customize the behavior of the preview. */ preview(opts?: PreviewOptions): Promise; /** * Compares the current stack’s resource state with the state known to exist in the actual * cloud provider. Any such changes are adopted into the current stack. * * @param opts Options to customize the behavior of the refresh. */ refresh(opts?: RefreshOptions): Promise; /** * Destroy deletes all resources in a stack, leaving all history and configuration intact. * * @param opts Options to customize the behavior of the destroy. */ destroy(opts?: DestroyOptions): Promise; /** * Returns the config value associated with the specified key. * * @param key The key to use for the config lookup */ getConfig(key: string): Promise; /** * Returns the full config map associated with the stack in the Workspace. */ getAllConfig(): Promise; /** * Sets a config key-value pair on the Stack in the associated Workspace. * * @param key The key to set. * @param value The config value to set. */ setConfig(key: string, value: ConfigValue): Promise; /** * Sets all specified config values on the stack in the associated Workspace. * * @param config The map of config key-value pairs to set. */ setAllConfig(config: ConfigMap): Promise; /** * Removes the specified config key from the Stack in the associated Workspace. * * @param key The config key to remove. */ removeConfig(key: string): Promise; /** * Removes the specified config keys from the Stack in the associated Workspace. * * @param keys The config keys to remove. */ removeAllConfig(keys: string[]): Promise; /** * Gets and sets the config map used with the last update. */ refreshConfig(): Promise; /** * Gets the current set of Stack outputs from the last Stack.up(). */ outputs(): Promise; /** * Returns a list summarizing all previous and current results from Stack lifecycle operations * (up/preview/refresh/destroy). */ history(pageSize?: number, page?: number): Promise; info(): Promise; /** * Cancel stops a stack's currently running update. It returns an error if no update is currently running. * Note that this operation is _very dangerous_, and may leave the stack in an inconsistent state * if a resource operation was pending when the update was canceled. * This command is not supported for local backends. */ cancel(): Promise; /** * exportStack exports the deployment state of the stack. * This can be combined with Stack.importStack to edit a stack's state (such as recovery from failed deployments). */ exportStack(): Promise; /** * importStack imports the specified deployment state into a pre-existing stack. * This can be combined with Stack.exportStack to edit a stack's state (such as recovery from failed deployments). * * @param state the stack state to import. */ importStack(state: Deployment): Promise; private runPulumiCmd; } /** * Returns a stack name formatted with the greatest possible specificity: * org/project/stack or user/project/stack * Using this format avoids ambiguity in stack identity guards creating or selecting the wrong stack. * Note that filestate backends (local file, S3, Azure Blob) do not support stack names in this * format, and instead only use the stack name without an org/user or project to qualify it. * See: https://github.com/pulumi/pulumi/issues/2522 * * @param org The org (or user) that contains the Stack. * @param project The project that parents the Stack. * @param stack The name of the Stack. */ export declare function fullyQualifiedStackName(org: string, project: string, stack: string): string; export interface OutputValue { value: any; secret: boolean; } export declare type OutputMap = { [key: string]: OutputValue; }; export interface UpdateSummary { kind: UpdateKind; startTime: Date; message: string; environment: { [key: string]: string; }; config: ConfigMap; result: UpdateResult; endTime: Date; version: number; Deployment?: RawJSON; resourceChanges?: OpMap; } /** * The kind of update that was performed on the stack. */ export declare type UpdateKind = "update" | "preview" | "refresh" | "rename" | "destroy" | "import"; /** * Represents the current status of a given update. */ export declare type UpdateResult = "not-started" | "in-progress" | "succeeded" | "failed"; /** * The granular CRUD operation performed on a particular resource during an update. */ export declare type OpType = "same" | "create" | "update" | "delete" | "replace" | "create-replacement" | "delete-replaced" | "read" | "read-replacement" | "refresh" | "discard" | "discard-replaced" | "remove-pending-replace" | "import" | "import-replacement"; /** * A map of operation types and their corresponding counts. */ export declare type OpMap = { [key in OpType]?: number; }; /** * An unstructured JSON string used for back-compat with versioned APIs (such as Deployment). */ export declare type RawJSON = string; /** * The deployment output from running a Pulumi program update. */ export interface UpResult { stdout: string; stderr: string; outputs: OutputMap; summary: UpdateSummary; } /** * Output from running a Pulumi program preview. */ export interface PreviewResult { stdout: string; stderr: string; changeSummary: OpMap; } /** * Output from refreshing the resources in a given Stack. */ export interface RefreshResult { stdout: string; stderr: string; summary: UpdateSummary; } /** * Output from destroying all resources in a Stack. */ export interface DestroyResult { stdout: string; stderr: string; summary: UpdateSummary; } /** * Options controlling the behavior of a Stack.up() operation. */ export interface UpOptions { parallel?: number; message?: string; expectNoChanges?: boolean; diff?: boolean; replace?: string[]; target?: string[]; targetDependents?: boolean; userAgent?: string; onOutput?: (out: string) => void; onEvent?: (event: EngineEvent) => void; program?: PulumiFn; } /** * Options controlling the behavior of a Stack.preview() operation. */ export interface PreviewOptions { parallel?: number; message?: string; expectNoChanges?: boolean; diff?: boolean; replace?: string[]; target?: string[]; targetDependents?: boolean; userAgent?: string; program?: PulumiFn; onOutput?: (out: string) => void; onEvent?: (event: EngineEvent) => void; } /** * Options controlling the behavior of a Stack.refresh() operation. */ export interface RefreshOptions { parallel?: number; message?: string; expectNoChanges?: boolean; target?: string[]; userAgent?: string; onOutput?: (out: string) => void; onEvent?: (event: EngineEvent) => void; } /** * Options controlling the behavior of a Stack.destroy() operation. */ export interface DestroyOptions { parallel?: number; message?: string; target?: string[]; targetDependents?: boolean; userAgent?: string; onOutput?: (out: string) => void; onEvent?: (event: EngineEvent) => void; }