Package com.pulumi.automation
Class WorkspaceStack
java.lang.Object
com.pulumi.automation.WorkspaceStack
- All Implemented Interfaces:
AutoCloseable
WorkspaceStack is an isolated, independently configurable instance of
a
Pulumi program. WorkspaceStack 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).
-
Method Summary
Modifier and TypeMethodDescriptionvoidaddEnvironments(Collection<String> environments) Adds environments to the end of the stack's import list.voidcancel()Cancel stops a stack's currently running update.voidchangeSecretsProvider(String newSecretsProvider) Change the secrets provider for a stack.voidchangeSecretsProvider(String newSecretsProvider, SecretsProviderOptions options) Change the secrets provider for the stack.voidclose()static WorkspaceStackCreates a new stack using the given workspace, and stack name.static WorkspaceStackcreateOrSelect(String name, Workspace workspace) 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 an existing stack.destroy()Destroy deletes all resources in a stack, leaving all history and configuration intact.destroy(DestroyOptions options) Destroy deletes all resources in a stack, leaving all history and configuration intact.Exports the deployment state of the stack.Returns the full config map associated with the stack in the Workspace.Returns the config value associated with the specified key.Returns the config value associated with the specified key.Returns a list summarizing all previews and current results from Stack lifecycle operations (up/preview/refresh/destroy).getHistory(HistoryOptions options) Returns a list summarizing all previews and current results from Stack lifecycle operations (up/preview/refresh/destroy).getInfo()Returns the current update summary for the stack.Gets the current set of Stack outputs from the lastup()call.Returns the value associated with the stack and key, scoped to the Workspace.voidimportStack(StackDeployment state) Imports the specified deployment state into a pre-existing stack.listTags()Returns the tag map for the specified stack name, scoped to the current Workspace.name()Gets the name identifying the Stack.preview()Performs a dry-run update to a stack, returning pending changes.preview(PreviewOptions options) Performs a dry-run update to a stack, returning pending changes.refresh()Compares the current stack's resource state with the state known to exist in the actual cloud provider.refresh(RefreshOptions options) Compares the current stack's resource state with the state known to exist in the actual cloud provider.Gets and sets the config map used with the last update.voidremoveAllConfig(Collection<String> keys) Removes the specified config keys from the Stack in the associated Workspace.voidremoveAllConfig(Collection<String> keys, boolean path) Removes the specified config keys from the Stack in the associated Workspace.voidremoveConfig(String key) Removes the specified config key from the Stack in the associated Workspace.voidremoveConfig(String key, boolean path) Removes the specified config key from the Stack in the associated Workspace.voidremoveEnvironment(String environment) Removes environments from the stack's import list.voidRemoves the specified key-value pair on the provided stack name.static WorkspaceStackSelects stack using the given workspace, and stack name.voidsetAllConfig(Map<String, ConfigValue> configMap) Sets all specified config values on the stack in the associated Workspace.voidsetAllConfig(Map<String, ConfigValue> configMap, boolean path) Sets all specified config values on the stack in the associated Workspace.voidsetConfig(String key, ConfigValue value) Sets the config key-value pair on the Stack in the associated Workspace.voidsetConfig(String key, ConfigValue value, boolean path) Sets the config key-value pair on the Stack in the associated Workspace.voidSets the specified key-value pair on the stack.state()Gets a module for editing the Stack's state.up()Creates or updates the resources in a stack by executing the program in the Workspace.Creates or updates the resources in a stack by executing the program in the Workspace.Gets the Workspace the Stack was created from.
-
Method Details
-
name
Gets the name identifying the Stack.- Returns:
- the stack name
-
workspace
Gets the Workspace the Stack was created from.- Returns:
- the workspace
-
state
Gets a module for editing the Stack's state.- Returns:
- the module for editing the stack's state
-
create
Creates a new stack using the given workspace, and stack name. It fails if a stack with that name already exists.- Parameters:
name- the name identifying the stackworkspace- the workspace the stack was created from- Returns:
- the stack
- Throws:
StackAlreadyExistsException- if a stack with the provided name already existsAutomationException- if an error occurs
-
select
Selects stack using the given workspace, and stack name. It returns an error if the given Stack does not exist.- Parameters:
name- the name identifying the stackworkspace- the workspace the stack was created from- Returns:
- the stack
- Throws:
StackNotFoundException- if a stack with the provided name does not existAutomationException- if an error occurs
-
createOrSelect
public static WorkspaceStack createOrSelect(String name, Workspace workspace) throws AutomationException 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 an existing stack. If the stack does not exist, it will be created and selected.- Parameters:
name- the name identifying the stackworkspace- the workspace the stack was created from- Returns:
- the stack
- Throws:
AutomationException- if an error occurs
-
getTag
Returns the value associated with the stack and key, scoped to the Workspace.- Parameters:
key- the key to use for the tag lookup- Returns:
- the value associated with the key
- Throws:
AutomationException- if an error occurs
-
setTag
Sets the specified key-value pair on the stack.- Parameters:
key- the tag key to setvalue- the tag value to set- Throws:
AutomationException- if an error occurs
-
removeTag
Removes the specified key-value pair on the provided stack name.- Parameters:
key- the tag key to remove- Throws:
AutomationException- if an error occurs
-
listTags
Returns the tag map for the specified stack name, scoped to the current Workspace.- Returns:
- the tag map for the specified stack name
- Throws:
AutomationException- if an error occurs
-
getConfig
Returns the config value associated with the specified key.- Parameters:
key- the key to use for the config lookup- Returns:
- the value associated with the key
- Throws:
AutomationException- if an error occurs
-
getConfig
Returns the config value associated with the specified key.- Parameters:
key- the key to use for the config lookuppath- the key contains a path to a property in a map or list to get- Returns:
- the value associated with the key
- Throws:
AutomationException- if an error occurs
-
getAllConfig
Returns the full config map associated with the stack in the Workspace.- Returns:
- the config map
- Throws:
AutomationException- if an error occurs
-
setConfig
Sets the config key-value pair on the Stack in the associated Workspace.- Parameters:
key- the config key to setvalue- the config value to set- Throws:
AutomationException- if an error occurs
-
setConfig
Sets the config key-value pair on the Stack in the associated Workspace.- Parameters:
key- the config key to setvalue- the config value to setpath- the key contains a path to a property in a map or list to set- Throws:
AutomationException- if an error occurs
-
setAllConfig
Sets all specified config values on the stack in the associated Workspace.- Parameters:
configMap- the map of config key-value pairs to set- Throws:
AutomationException- if an error occurs
-
setAllConfig
public void setAllConfig(Map<String, ConfigValue> configMap, boolean path) throws AutomationExceptionSets all specified config values on the stack in the associated Workspace.- Parameters:
configMap- the map of config key-value pairs to setpath- the keys contain a path to a property in a map or list to set- Throws:
AutomationException- if an error occurs
-
removeConfig
Removes the specified config key from the Stack in the associated Workspace.- Parameters:
key- the config key to remove- Throws:
AutomationException- if an error occurs
-
removeConfig
Removes the specified config key from the Stack in the associated Workspace.- Parameters:
key- the config key to removepath- the key contains a path to a property in a map or list to remove- Throws:
AutomationException- if an error occurs
-
removeAllConfig
Removes the specified config keys from the Stack in the associated Workspace.- Parameters:
keys- the config keys to remove- Throws:
AutomationException- if an error occurs
-
removeAllConfig
Removes the specified config keys from the Stack in the associated Workspace.- Parameters:
keys- the config keys to removepath- the keys contain a path to a property in a map or list to remove- Throws:
AutomationException- if an error occurs
-
refreshConfig
Gets and sets the config map used with the last update.- Returns:
- the config map used with the last update
- Throws:
AutomationException- if an error occurs
-
addEnvironments
Adds environments to the end of the stack's import list. Imported environments are merged in order per the ESC merge rules. The list of environments behaves as if it were the import list in an anonymous environment.- Parameters:
environments- list of environments to add to the end of the stack's import list- Throws:
AutomationException- if an error occurs
-
removeEnvironment
Removes environments from the stack's import list.- Parameters:
environment- the name of the environment to remove from the stack's configuration- Throws:
AutomationException- if an error occurs
-
changeSecretsProvider
Change the secrets provider for a stack.- Parameters:
newSecretsProvider- the new secrets provider- Throws:
AutomationException- if an error occurs
-
changeSecretsProvider
public void changeSecretsProvider(String newSecretsProvider, @Nullable SecretsProviderOptions options) throws AutomationException Change the secrets provider for the stack.- Parameters:
newSecretsProvider- the new secrets provideroptions- the options to change the secrets provider- Throws:
AutomationException- if an error occurs
-
up
Creates or updates the resources in a stack by executing the program in the Workspace.https://www.pulumi.com/docs/reference/cli/pulumi_up/
- Returns:
- the result of the update
- Throws:
AutomationException- if an error occurs
-
up
Creates or updates the resources in a stack by executing the program in the Workspace.https://www.pulumi.com/docs/reference/cli/pulumi_up/
- Parameters:
options- options to customize the behavior of the update- Returns:
- the result of the update
- Throws:
AutomationException- if an error occurs
-
preview
Performs a dry-run update to a stack, returning pending changes.- Returns:
- the result of the preview
- Throws:
AutomationException- if an error occurs
-
preview
Performs a dry-run update to a stack, returning pending changes.- Parameters:
options- options to customize the behavior of the update- Returns:
- the result of the preview
- Throws:
AutomationException- if an error occurs
-
refresh
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.- Returns:
- the result of the refresh
- Throws:
AutomationException- if an error occurs
-
refresh
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.- Parameters:
options- options to customize the behavior of the refresh- Returns:
- the result of the refresh
- Throws:
AutomationException- if an error occurs
-
destroy
Destroy deletes all resources in a stack, leaving all history and configuration intact.- Returns:
- the result of the destroy
- Throws:
AutomationException- if an error occurs
-
destroy
Destroy deletes all resources in a stack, leaving all history and configuration intact.- Parameters:
options- options to customize the behavior of the destroy- Returns:
- the result of the destroy
- Throws:
AutomationException- if an error occurs
-
getOutputs
Gets the current set of Stack outputs from the lastup()call.- Returns:
- the current set of stack outputs
- Throws:
AutomationException- if an error occurs
-
getHistory
Returns a list summarizing all previews and current results from Stack lifecycle operations (up/preview/refresh/destroy).- Returns:
- the list of summaries
- Throws:
AutomationException- if an error occurs
-
getHistory
Returns a list summarizing all previews and current results from Stack lifecycle operations (up/preview/refresh/destroy).- Parameters:
options- options to customize the behavior of the fetch history action- Returns:
- the list of summaries
- Throws:
AutomationException- if an error occurs
-
exportStack
Exports the deployment state of the stack.This can be combined with
importStack(com.pulumi.automation.StackDeployment)to edit a stack's state (such as recovery from failed deployments).- Returns:
- the deployment state of the stack
- Throws:
AutomationException- if an error occurs
-
importStack
Imports the specified deployment state into a pre-existing stack.This can be combined with
exportStack()to edit a stack's state (such as recovery from failed deployments).- Parameters:
state- the deployment state to import- Throws:
AutomationException- if an error occurs
-
getInfo
Returns the current update summary for the stack.- Returns:
- the current update summary for the stack
- Throws:
AutomationException- if an error occurs
-
cancel
Cancel stops a stack's currently running update. It throws an exception 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.- Throws:
AutomationException- if an error occurs
-
close
- Specified by:
closein interfaceAutoCloseable- Throws:
Exception
-