For those that use pulumi to create ephemeral envi...
# general
b
For those that use pulumi to create ephemeral environments, how are you handling stack cleanup? I can handle resource cleanup in k8s with a CronJob but the stacks are still left over with their state intact. Once a branch is merged and deleted, CI doesn’t really do anything at that point.
👍 1
g
The CIs that I have used do have an event for deleted branches. You can have a job at that point to run
pulumi destroy
Which CI are you using?
b
The cleanup could be done like this (in gitlab job format)
Copy code
stop_env:
  image: 
    name: pulumi/pulumi:v1.10.1
    entrypoint: [""]
  variables:
    GIT_STRATEGY: none
  script:
    - |
      echo "name: project-name" > Pulumi.yaml
    - |
      echo "runtime: nodejs" >> Pulumi.yaml
    - pulumi destroy --stack ${CI_COMMIT_REF_NAME} --non-interactive
${CI_COMMIT_REF_NAME} --non-interactive
  environment:
    name: ${CI_COMMIT_REF_NAME}
    action: stop
  when: manual
But, in our side, creating a new stack with secret is not as easy
m
I run a CI job tied to a branch deletion event from github.
👋 2
b
I’m on CircleCI, not sure if a deletion steps are possible on that
m
Yeah not sure either, haven’t used it for a bit. Is there a way to set up a generic webhook trigger?
Maybe a github webhook triggering the workflow API if CircleCI ever released that
b
Yeah I think I could do it via webhook somehow, just seems jank
m
It’s pretty jank everywhere except GH actions which has built-in semantic support for all of the event types
b
Github actions: so hot rn
👀 1