Hi guys, any help would be much appreciated! I am...
# general
l
Hi guys, any help would be much appreciated! I am looking for a way to clean up stale dev stacks (no actual resources, just api object in pulumi api). My thought was to list all projects, then iterate over those with
pulumi stack ls -p $PROJECT
and destroy whatever is redundant. Is there an easy way to list all projects for my organisation using the cli or api (couldn't find such cmd)? Also using
pulumi stack ls -a
could be a good for the job, but it is limited to 300 results and we currenly have >3000.
👀 2
b
Are you using Pulumi as a backend?
l
yes
b
It is possible to use the API, but worth noting that it's not well documented and whilst publicly available, is mainly for our service and CLI to talk to. Having said that, you could use it here. You'll need an access token (which you can get from the Pulumi console)
Then you can run:
Copy code
curl \
    -H 'Accept: application/vnd.pulumi+3' \
    -H 'Authorization: token abcdefghijklmnopqrstuvwxyz' \
    -H 'Content-Type: application/json' \
    <https://api.pulumi.com/api/user/stacks>
You can also filter using querystrings:
?organization=org-name&project=gke-app-test
As I said before, the API is liable to change without warning (although probably not too much because we use it for the CLI and need to be able to handle older versions of the CLI)
l
Cool I'll try that I hope this is just a one time operation as probably caused by a bug a while back. 10x @brave-planet-10645 !
b
Let me know how you get on and if you need anything further 🙂
l
Hey @brave-planet-10645 This is also limited to 300 results, is there a way to get all?
b
Let me find out if we have paging on it
It might be that you'll have to start with that and then once you've deleted all 300 then make the call again