Hi everyone, I suspect my question went unnoticed ...
# general
p
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
cc @clever-sunset-76585 again 🙂
c
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
@clever-sunset-76585 Sure - what’s the repo?
c
p
@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
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
+1 for this