https://pulumi.com logo
#general
Title
# general
g

gorgeous-pillow-13604

01/08/2024, 8:04 PM
What is the best way to catch an error with the Pulumi CLI when running "pulumi stack select" so I can run "pulumi stack init" if it fails?
v

victorious-art-92103

01/08/2024, 8:19 PM
I would say wrap over it with some tooling that uses createOrSelectStack: https://www.pulumi.com/docs/reference/pkg/nodejs/pulumi/pulumi/automation/#LocalWorkspace-createOrSelectStack
If you need to do it in the shell,
pulumi stack select -s <stack>
will return non-zero if it can't select the stack. Check for non-zero and init as needed.