pulumi / circleci

CircleCI Orbs for CI/CD using Pulumi.
Apache License 2.0
20 stars 15 forks source link

pulumi stack init || pulumi stack select #30

Closed kostas-theo closed 3 years ago

kostas-theo commented 3 years ago

Small addition of the pulumi stack select command into the pulumi/stack_init orb.

Currently, if you add pulumi/stack_init into your circleci pipeline, you will have to remove that command in the very next run, as this command is only intended to be run once, and will fail after the first run with:

error: stack '<organization>/<project>' already exists

This change adds the pulumi stack select afterwards if the above error occurs, resulting in a consistent pipeline for new and existing projects.

chrsmith commented 3 years ago

Hey @roachmd ! So sorry for dropping the ball here. I really appreciate the PR, but I don't think we want to actually go with this approach.

First, there are several reasons why pulumi stack init could fail. And so running pulumi stack select on any non-zero exit code doesn't seem right. But more importantly, I think the right approach when using Pulumi in CI would be to use the pulumi stack select --create gesture.

I don't recall exactly when this feature was added, but you can run pulumi stack select with a --create flag that will create the stack if it doesn't already exist. That way, things will "just work" even if it is the first time referencing that particular stack name.

https://www.pulumi.com/docs/reference/cli/pulumi_stack_select/

Unfortunately we don't have a pulumi/stack_select orb yet. I'll file an issue so we can track adding that, which would be generally useful for other scenarios as well.