We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 001f429 commit 080c7c4Copy full SHA for 080c7c4
deployment/cleanup.sh
@@ -1,10 +1,11 @@
1
#!/bin/sh
2
-
+#set -xv
3
BUCKET=$1
4
+# test if an s3 bucket exists and delete all objects and delete markers from it
5
+# if it does not exist, just print a message
6
+bucketExists=`aws s3api list-buckets --query "Buckets[].Name" | grep -w "$BUCKET" | wc -l`
7
-bucketExists=$(aws s3api head-bucket --bucket "$BUCKET" 2>/dev/null && echo "yes" || echo "no")
-echo "BucketExists: $bucketExists"
-if [ "$bucketExists" = "yes" ]
8
+if [ "$bucketExists" -eq 1 ]
9
then
10
objects=$(aws s3api list-object-versions --bucket "$BUCKET" --no-paginate --output=json --query='{Objects: Versions[].{Key:Key,VersionId:VersionId}}')
11
count=$(awk '/"Objects": null/ {print}' <<< "$objects" | wc -l)
0 commit comments