Skip to content

Commit

Permalink
Add workflow to purge RDS snapshots (#947)
Browse files Browse the repository at this point in the history
* Adding purge aws rds snapshots workflow

Signed-off-by: willdavsmith <willdavsmith@gmail.com>

* Adding purge aws rds snapshots workflow

Signed-off-by: willdavsmith <willdavsmith@gmail.com>

---------

Signed-off-by: willdavsmith <willdavsmith@gmail.com>
  • Loading branch information
willdavsmith authored Jan 24, 2024
1 parent 5939bd6 commit 555acf4
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
23 changes: 23 additions & 0 deletions .github/scripts/purge-aws-rds-snapshots.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# ------------------------------------------------------------
# Copyright 2023 The Radius Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ------------------------------------------------------------

set -xe

aws rds describe-db-snapshots --query 'DBSnapshots[].DBSnapshotIdentifier' --output text > snapshots.txt
for rds_snapshot_identifier in $(cat ./snapshots.txt)
do
aws rds delete-db-snapshot --db-snapshot-identifier $rds_snapshot_identifier
done
19 changes: 19 additions & 0 deletions .github/workflows/purge-aws-rds-snapshots.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Purge AWS RDS DBInstance snapshots
on:
schedule:
# Runs at 00:30 and 12:30
- cron: "30 0,12 * * *"
jobs:
purge_rds_snapshots:
name: Purge AWS RDS DBInstance snapshots
runs-on: [ubuntu-latest]
steps:
- name: Purge AWS RDS DBInstance snapshots
run: |
./.github/scripts/purge-aws-rds-snapshots.sh
- name: Create GitHub issue on failure
if: ${{ failure() }}
run: |
gh issue create --title "Purge AWS RDS DBInstance snapshots workflow failed" \
--body "Test failed on ${{ github.repository }}. See [workflow logs](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) for more details." \
--repo ${{ github.repository }}

0 comments on commit 555acf4

Please sign in to comment.