There currently isn’t a way to delete all stacks with pulumi stack rm
so this is an alternative way to achieve that.
Delete All Stacks in the Current Project
To delete all Pulumi stacks in the current Pulumi project you can run the following command:
|
|
Delete All Stacks Across All Projects
Be careful when doing this.
To delete all Pulumi stacks across all Pulumi projects we need to use pulumi stack ls -a
instead of pulumi stack ls
. So the full command is:
|
|
Command Break Down
List pulumi stacks (use -a
option for all stacks across all projects):
|
|
Start at the second line of the previous output:
|
|
Delete all occurrences of *
. There is a *
character next to the currently selected stack and we need to remove this:
|
|
Print only the first column:
|
|
This is a loop in one-liner format. It reads the previous output line by line and assigns each line to an array called stack
, then runs the command pulumi stack rm -y
on each stack.
|
|