Hm, if I used a git branch per pulumi stack for de...
# general
a
Hm, if I used a git branch per pulumi stack for dev/stage/prod would it be wise to create a githook to execute a stack switch with pulumi upon git checkout to another branch?
b
Effectively, that's exactly right. The specific details do depend a lot on what CI/CD system you're using, although you say "githook" so I wonder, are you doing this without a CI/CD server and wanting to execute the commands as local git hooks? For CI, there are some good pointers here: https://pulumi.io/reference/cd-travis/. If you end up down the road breaking your project into many stacks, you'll need something like https://blog.pulumi.com/continuous-delivery-with-gitlab-and-pulumi-on-amazon-eks, however if you're sticking to "monolithic" stacks for dev/stage/prod (by far, the easiest option), then the CI/CD docs above should suffice.
a
Awesome thank you! We're doing it manually in the terminal first to get the dev team used to all these new tools, then will automate with CI/CD. Yup we're monolithic for the most part out the gate.
b
Sounds great -- don't hesitate to reach out if you have any other questions.
a
kk got it 🙂 appreciate it
b
Because it's java script, your flexibility is high! Consider a build script, using any of multiple task runners, or your own task runner where you:
Copy code
const BRANCH = execSync(`git rev-parse --abbrev-ref HEAD`).toString('utf8').trim()
const STACK = `exampleOrg/${BRANCH}`

var tasks = {
  update: () => {
    sh(`pulumi update -y --skip-preview --stack ${STACK}`)
    tasks.test()
  }
  ,test: () => {
    sh(`npm ${options.debug? 'run test-debug':'test'}`)
  }
}
You can even get the branch from inside your index.ts script and change up your stack inputs from the same stack, based on what branch you are on.
a
awesome thanks for the tip!