Hello :wave:, I'm trying to setup ci/cd using pulu...
# general
s
Hello ๐Ÿ‘‹, I'm trying to setup ci/cd using pulumi and circleci (pulumi orb), but I'm having an issue with
pulumi/stack_init
step as it fails because of the already existing stack. Is there any way how to select stack if it exists or init new one if doesn't other than piping command's stderr to null output so that my circleci job doesn't fail? This is my circleci job config:
Copy code
jobs:
  deploy-infra:
    <<: *default-executor
    working_directory: ~/project/infrastructure
    steps:
      - checkout:
          path: ../
      - node/install-packages
      - pulumi/login
      - pulumi/stack_init:
          stack: 'dev'
      - run:
          name: Add stack config
          command: |
            pulumi config set aws:region us-east-1
            pulumi config set bucket:name cicd-test-bucket
      - pulumi/update:
          stack: 'dev'
I can assign build number to stack name like it's in the orb example:
Copy code
- pulumi/stack_init:
          stack: 'robot-co/test-pr_${CIRCLE_BUILD_NUM}'
but I don't want to create new stack and new resources on every ci/cd trigger, I just want to have 3 stacks which are
dev
,
staging
and
prod
.
w
Of course if the dev, staging, prod stacks already exist then you can forget about the stack_init step. The
pulumi/update
command will just run against the provide stack. However, if you canโ€™t assume that, then maybe this blog about how to ignore a failed step will work: https://support.circleci.com/hc/en-us/articles/360057590591-Ignoring-A-Failure-In-A-Step So you can do the stack_init and if it fails because the stack already exists, you continue.
๐Ÿ‘ 1
s
Thanks! ๐Ÿ™Œ