Skip to content

Instantly share code, notes, and snippets.

@KoheiKanagu
Last active September 22, 2023 05:03
Show Gist options
  • Save KoheiKanagu/f8dd1938d6a45b5f6ef1731fb752cbfa to your computer and use it in GitHub Desktop.
Save KoheiKanagu/f8dd1938d6a45b5f6ef1731fb752cbfa to your computer and use it in GitHub Desktop.
#!/bin/bash
set -euxo pipefail
echo '
[
{
"name": "delete_all",
"action": {
"type": "Delete"
},
"condition": {
"olderThan": "1d"
}
}
]
' >policy_delete_all.json
PROJECTS=(
# FIXME: Add your project IDs here
)
LOCATIONS=(
# FIXME: Add your locations here
'asia-northeast1'
'us-central1'
)
for PROJECT in "${PROJECTS[@]}"; do
for LOCATION in "${LOCATIONS[@]}"; do
gcloud artifacts repositories set-cleanup-policies gcf-artifacts \
--project="$PROJECT" \
--location="$LOCATION" \
--policy="policy_delete_all.json" \
--no-dry-run
done
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment