I have several projects with multiple stacks in my...
# general
g
I have several projects with multiple stacks in my organization. But a lot of those stacks do not seem to have any infrastructure (on Azure) anymore for various reasons (maybe they were never pulumi up'd or maybe they were destroyed.) How do I (programatically since there are so many) figure out which stacks can be deleted safely. I could not find any good documentation on this. It seems that you can look for
outputs
and if there are none, then it should be free to delete. But that doesn't seem right. If there is not a programatic way, what is the best way to do this in the ui?
l
A simple
pulumi stack ls
(optionally with a
--cwd
pointing to a project) will list all the stacks in a project, along with the number of managed resources. Any stack with zero resources is safe to delete.
If you're not sure if that's an accurate number, you should be able to script up something that runs
pulumi refresh
on each stack first.
g
ok thanks for the info. zero resources sounds like the key to this!
@little-cartoon-10569 regarding
pulumi refresh
do I have to have to have the respective
pulumi up
code on my computer to run? That code is in a bunch of different repos. Or can I somehow just do it by pulling the state of the stack.
l
I've never tried running it without the code there. You definitely need to specify the project and stack, but that's possible with command-line arguments. And refresh at least theoretically involves only the state and the cloud. But you'd have to try to find out.