When issuing `pulumi stack init` on an existing st...
# general
c
When issuing
pulumi stack init
on an existing stack, is there a way to ignore the fact that it already exists? Use case: Looking at a way to create stacks on the fly without needing to do a lookup of sorts before issuing an
init
.
c
+1. I ended up doing the init and swallowing the error. I see the github actions (& the automation API) has support for upsert, but not the CLI.
pulumi stack ls | grep somestackname
as an alternative..
Using the Pulumi CLI in a GH action step:
Copy code
- name: Create new pr stack
      run: |
        pulumi stack init --non-interactive --logtostderr "${{ env.STACK_NAME }}" 
      working-directory: ./infra
      env:
        PULUMI_ACCESS_TOKEN: ${{ secrets.PULUMI_ACCESS_TOKEN }}
      continue-on-error: true # init fails if exists
👍 1
c
Thanks @chilly-analyst-14900!
s
It would be nice if
pulumi stack select
had a flag like --auto-create if it didn't exist
because then you wouldn't have to worry about initializing it, as the stack select would initialize it.. and if it already exists, it would just select it.