cloud-platform icon indicating copy to clipboard operation
cloud-platform copied to clipboard

Clean up snapshots older than 1 year

Open vijay-veeranki opened this issue 2 years ago • 0 comments

Background

To reduce cost and improve security on the platform we need to delete old EBS snapshots.

Proposed user journey

Run this script in the concourse pipeline scheduling it every day.

year_older=$( date -v  -1y +"%Y-%m-%d" )

----- Delete older than 1 year for all snapshots
for K in $(aws ec2 describe-snapshots \
    --owner-ids 754256621582  \
    --region=eu-west-2  \
    --query "Snapshots[?(StartTime <'${year_older}')].[SnapshotId]" --output text); do
echo "deleting ${K}"
aws ec2 --region eu-west-2 delete-snapshot --snapshot-id $K
echo "Successfully deleted snapshot ${K}"
done
-----
----- Delete older than 3 months for velero snapshots
for K in $(aws ec2 describe-snapshots \
    --owner-ids 754256621582  \
    --region=eu-west-2  \
    --filters "Name=tag:velero.io/schedule-name,Values=velero-allnamespacebackup" \
    --query "Snapshots[?(StartTime <'${year_older}')].[SnapshotId]" --output text); do
echo "deleting ${K}"
aws ec2 --region eu-west-2 delete-snapshot --snapshot-id $K
echo "Successfully deleted snapshot ${K}"
done
-----

Approach

Clean up old snapshots using pipeline running script to delete snapshots

Which part of the user docs does this impact

Questions / Assumptions

Definition of done

  • [ ] Old EBS snapshots older than 1 year cleaned up

Reference

How to write good user stories

vijay-veeranki avatar Sep 05 '22 12:09 vijay-veeranki