Skip to content

Commit

Permalink
attempts to select the stack before creating
Browse files Browse the repository at this point in the history
Creating a stack requires admin permissions, where selecting does not.
  • Loading branch information
denniswebb committed Oct 21, 2022
1 parent 79c0af7 commit 7695311
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
@@ -0,0 +1,4 @@
changes:
- type: fix
scope: sdk/python
description: pulumi.automation.create_or_select_stack() attempts to select the stack before attempting to create
4 changes: 2 additions & 2 deletions sdk/python/lib/pulumi/automation/_stack.py
Expand Up @@ -186,9 +186,9 @@ def __init__(self, name: str, workspace: Workspace, mode: StackInitMode) -> None
workspace.select_stack(name)
elif mode is StackInitMode.CREATE_OR_SELECT:
try:
workspace.create_stack(name)
except StackAlreadyExistsError:
workspace.select_stack(name)
except StackNotFoundError:
workspace.create_stack(name)

def __repr__(self):
return f"Stack(stack_name={self.name!r}, workspace={self.workspace!r}, mode={self._mode!r})"
Expand Down

0 comments on commit 7695311

Please sign in to comment.