Skip to content

Commit

Permalink
fixup
Browse files Browse the repository at this point in the history
Signed-off-by: jayfranco999 <[email protected]>
  • Loading branch information
jayfranco999 committed Nov 27, 2024
1 parent 81c9f36 commit 4777121
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions cleanup/aws_snapshots.sh
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,14 @@ if [ -n "${snapshot_ids}" ]; then

for snapshot_id in ${snapshot_ids}; do
echo "== Attempting to delete snapshot: ${snapshot_id}"
if ! run_aws_ec2_command delete-snapshot --snapshot-id "${snapshot_id}" 2>/dev/null; then
# Log and skip snapshots that are in use
echo "[WARNING] Snapshot ${snapshot_id} is currently in use. Skipping."
if ! output=$(run_aws_ec2_command delete-snapshot --snapshot-id "${snapshot_id}" 2>&1); then
if echo "${output}" | grep -q "InvalidSnapshot.InUse"; then
# Log and skip snapshots that are in use
echo "[WARNING] Snapshot ${snapshot_id} is currently in use. Skipping."
else
# Log unexpected errors
echo "[ERROR] Failed to delete snapshot ${snapshot_id}: ${output}"
fi
continue
fi
echo "== Snapshot ${snapshot_id} successfully deleted."
Expand Down

0 comments on commit 4777121

Please sign in to comment.