https://pulumi.com logo
Title
b

brave-winter-60074

06/07/2021, 9:24 AM
Hi everyone, is there a way to clean up your pulumi organization. We have a microservice setup and have been on a learning curve with pulumi to obtain our end goal and have a lot of mess in our pulumi account do to trial and error plus internal restrictions. This is just one project and we have 10+ Thought that I could create a new organization and then transition to that so that we start from scratch. But as far as i see only one organization is allowed? Seems like an enormous work if we have to destroy and remove all stacks on all projects most of them are deleted in azure with az group delete on the resource group… Thanx in advance
p

proud-pizza-80589

06/07/2021, 9:29 AM
I have bash script to delete a selection of dynamically created stacks
#!/usr/bin/env bash

# Pulumi.yaml
echo "name: bpaas" > Pulumi.yaml
echo "runtime: nodejs" >> Pulumi.yaml

STACKS=$(pulumi stack ls -j | jq -r ".[].name" | sed "s/settlemint\///")
while read -r stack; do
  # Pulumi.development-gke-europe-test24.yaml
  pulumi stack select settlemint/bpaas/${stack}
  pulumi config refresh

  # Cancel
  pulumi cancel --yes -s settlemint/bpaas/${stack}

  # Failed states
  pulumi stack export | jq "del(.deployment.pending_operations)" | pulumi stack import

  # Destroy
  pulumi destroy --yes -s settlemint/bpaas/${stack} --refresh

  # Remove stack
  pulumi stack rm --yes settlemint/bpaas/${stack} --force
done <<< "$STACKS"
👍 1
b

brave-winter-60074

06/07/2021, 10:13 AM
NICE THANK YOU
p

proud-pizza-80589

06/07/2021, 10:52 AM
please dry run it first before it kills your prod env 😉
💯 1