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

handsome-truck-95168

11/19/2019, 8:28 PM
Using the CLI, is it possible to tell if a given stack exists? Similarly, can I check if a given stack is currently "leased"?
I'm using pulumi to deploy instances of our app for PRs; I have a script that runs when the PR is first opened and on each update. In all cases I'm creating (or updating) a stack specific to that PR.
I'd like to know if a stack exists yet because I have to run
init
at least once. Right now, I run it everytime but trap the error in cases where the stack already exists.
h

handsome-actor-1155

11/19/2019, 8:31 PM
You can run
pulumi stack
and check the output to see if any resources are allocated for it
h

handsome-truck-95168

11/19/2019, 8:33 PM
Not sure that will work when the stack doesn't exist. I get a terminal prompt asking if I want to create the stack. I don't know the behavior when their isn't a tty (i.e., running in a CI environment).
I'd like to know if the stack is currently being updated because I'd like to bail out of the deployment script early if that's the case.
c

colossal-beach-47527

11/20/2019, 12:13 AM
I don’t believe there are ways to do this in the
pulumi
CLI today, short of running a command and grepping for specific error messages / exit codes. (You can set an environment variable
TERM=dumb
, which will skip interactive prompts.) But this is a good suggestion, as we’d like to better this type of scenario. Could you please file an issue on github.com/pulumi/pulumi? If we can’t think of a good UX for adding a command-line verb, at the very least we can probably add an endpoint to our REST API that you can script using
curl
.
👍 1
h

handsome-truck-95168

11/20/2019, 3:00 AM
3 Views