aboutsummaryrefslogtreecommitdiff
path: root/gcloud-image-cleanup.aww
diff options
context:
space:
mode:
authorShulhan <ms@kilabit.info>2023-01-07 14:40:40 +0700
committerShulhan <ms@kilabit.info>2023-02-11 14:23:16 +0700
commite64dc6ad3d159450a65ddcc5a35f08a5d65eea85 (patch)
tree3d37e0bcadede688a94ba9fca5129dd54a860d28 /gcloud-image-cleanup.aww
parent1c986750dc494c67438d88920200d6245646d8dc (diff)
downloadcompute-archlinux-image-builder-e64dc6ad3d159450a65ddcc5a35f08a5d65eea85.tar.xz
all: add script to delete all images except the last five
Diffstat (limited to 'gcloud-image-cleanup.aww')
-rw-r--r--gcloud-image-cleanup.aww20
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)"