diff options
| author | Shulhan <ms@kilabit.info> | 2023-01-07 14:40:40 +0700 |
|---|---|---|
| committer | Shulhan <ms@kilabit.info> | 2023-02-11 14:23:16 +0700 |
| commit | e64dc6ad3d159450a65ddcc5a35f08a5d65eea85 (patch) | |
| tree | 3d37e0bcadede688a94ba9fca5129dd54a860d28 | |
| parent | 1c986750dc494c67438d88920200d6245646d8dc (diff) | |
| download | compute-archlinux-image-builder-e64dc6ad3d159450a65ddcc5a35f08a5d65eea85.tar.xz | |
all: add script to delete all images except the last five
| -rw-r--r-- | gcloud-image-cleanup.aww | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/gcloud-image-cleanup.aww b/gcloud-image-cleanup.aww new file mode 100644 index 0000000..955b5cb --- /dev/null +++ b/gcloud-image-cleanup.aww @@ -0,0 +1,20 @@ +## Script to remove all except the last five images. + +#require: gcloud config configurations activate {{.Val "gcloud::config"}} + +gcloud compute images list \ + --no-standard-images \ + --show-deprecated \ + --format="value(NAME)" + +gcloud compute images list \ + --no-standard-images \ + --show-deprecated \ + --format="value(NAME)" \ + | head --lines=-5 \ + | xargs gcloud compute images delete --quiet + +gcloud compute images list \ + --no-standard-images \ + --show-deprecated \ + --format="value(NAME)" |
