Clean Up AWS Resources #704
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Clean Up AWS Resources | |
on: | |
schedule: | |
- cron: '5 9 * * *' # every day at 9:05 am UTC | |
jobs: | |
cleanup: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Install Nix | |
uses: DeterminateSystems/nix-installer-action@v16 | |
- run: echo "NIXPKGS_ALLOW_UNFREE=1" >> $GITHUB_ENV | |
- name: Use the Magic Nix Cache | |
uses: DeterminateSystems/magic-nix-cache-action@v8 | |
- name: Cache Clojure dependencies | |
uses: actions/cache@v4 | |
with: | |
key: clj-${{ github.repository }}-${{ hashFiles('**/deps.edn') }} | |
restore-keys: clj-${{ github.repository }}- | |
path: | | |
~/.gitlibs | |
~/.m2/repository | |
- name: Configure AWS credentials | |
uses: aws-actions/configure-aws-credentials@v4 | |
with: | |
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
aws-region: us-east-1 | |
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
mask-aws-account-id: no | |
- name: Build devShell | |
run: nix build --impure .#devShells.x86_64-linux.default | |
- name: Run cleanup | |
# Make sure that no one forks this and accidentally | |
# deletes all their stuff. | |
if: ${{ github.repository }} == 'john-shaffer/salmon' | |
run: | | |
nix develop --impure -c clj -X salmon.cleanup/delete-all-stacks! :confirm? true :regions "[:us-east-1 :us-east-2 :us-west-2]" | |
nix develop --impure -c clj -X salmon.cleanup/deregister-all-amis! :confirm? true :regions "[:us-east-1 :us-east-2 :us-west-2]" | |
nix develop --impure -c clj -X salmon.cleanup/delete-orphaned-snapshots! :confirm? true :regions "[:us-east-1 :us-east-2 :us-west-2]" |