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

powerful-football-81694

01/17/2020, 1:22 PM
Hi everyone, I suspect my question went unnoticed so I’m bumping it, and clarifying a bit. I’m looking for a way to create a new stack as part of a DevOps pipeline. The stack name could for example be input using a user-configurable pipeline variable, or it could be the name of the branch that triggered the build. I want to use the Pulumi Task Extension for Azure Pipelines to initialize a new stack if it does not already exist. The obvious thing to try is to use set
command: stack
and
options: init $(StackName)
in the YAML. However, the
Pulumi@1
task has a mandatory
stack
parameter, and the task always tries to select that stack the first thing it does, before it proceeds to execute the actual command, which of course results in an error because the stack does not yet exist.
t

tall-librarian-49374

01/17/2020, 1:44 PM
cc @clever-sunset-76585 again 🙂
c

clever-sunset-76585

01/17/2020, 2:59 PM
Ah yes. I thought about making the stack input optional for this very reason, but didn't because well it hadn't come up till now. Mind opening an issue?
p

powerful-football-81694

01/17/2020, 3:44 PM
@clever-sunset-76585 Sure - what’s the repo?
c

clever-sunset-76585

01/17/2020, 4:01 PM
p

powerful-football-81694

01/17/2020, 4:21 PM
@clever-sunset-76585 wouldn’t it make more sense if the
stack
parameter remained required, and you added a
stack init
command to the task, that uses this parameter for the stack init, but does not try to do the select first?
Such a
stack init
command could then also “swallow” the error that occurs if the stack already exists. Something we would otherwise need to do in the pipeline.
c

clever-sunset-76585

01/17/2020, 5:09 PM
Yep that’s what I am thinking too. There is a need for an “ephemeral” stack capability in Pulumi itself and I think there is an issue open in
pulumi/pulumi
. I implemented a similar thing for our Octopus Deploy Step Template too. It allows you to create a stack of if it does not exist.
m

miniature-chef-87843

01/20/2020, 8:34 PM
+1 for this