From 81154e8943c2479affe75f38952a09f39b0ac14e Mon Sep 17 00:00:00 2001 From: Amit Kumar Date: Thu, 3 Aug 2023 21:28:11 +0100 Subject: [PATCH] Trying cloud-nuke to clear aws resources --- .github/workflows/test_integration.yaml | 23 +++++++++++---- .../scripts/cloud-nuke-config.yml | 0 tests/scripts/nuke-aws.sh | 28 +++++++++++++++++++ 3 files changed, 46 insertions(+), 5 deletions(-) rename cloud-nuke-config.yml => tests/scripts/cloud-nuke-config.yml (100%) create mode 100755 tests/scripts/nuke-aws.sh diff --git a/.github/workflows/test_integration.yaml b/.github/workflows/test_integration.yaml index 00253d067e..721573dbb3 100644 --- a/.github/workflows/test_integration.yaml +++ b/.github/workflows/test_integration.yaml @@ -1,6 +1,7 @@ name: "Integration Tests" on: + push: schedule: - cron: "0 0 * * MON" workflow_dispatch: @@ -16,8 +17,8 @@ jobs: matrix: provider: - aws - - do - - gcp +# - do +# - gcp fail-fast: false steps: - name: "Checkout Infrastructure" @@ -85,7 +86,19 @@ jobs: echo "SPACES_SECRET_ACCESS_KEY=${{ secrets.SPACES_SECRET_ACCESS_KEY }}" >> $GITHUB_ENV echo "NEBARI_K8S_VERSION"=1.25.12-do.0 >> $GITHUB_ENV - - name: Integration Tests +# - name: Integration Tests +# run: | +# pytest --version +# pytest tests/tests_integration/ -vvv -s -m ${{ matrix.provider }} + + - name: Cloud Nuke AWS + if: ${{ matrix.provider == 'aws' && always()}} run: | - pytest --version - pytest tests/tests_integration/ -vvv -s -m ${{ matrix.provider }} + mkdir -p bin + pushd bin + wget https://github.com/gruntwork-io/cloud-nuke/releases/download/v0.32.0/cloud-nuke_linux_amd64 + mv cloud-nuke_linux_amd64 cloud-nuke + chmod +x cloud-nuke + echo "$PWD" >> $GITHUB_PATH + popd + ./tests/scripts/nuke-aws.sh diff --git a/cloud-nuke-config.yml b/tests/scripts/cloud-nuke-config.yml similarity index 100% rename from cloud-nuke-config.yml rename to tests/scripts/cloud-nuke-config.yml diff --git a/tests/scripts/nuke-aws.sh b/tests/scripts/nuke-aws.sh new file mode 100755 index 0000000000..5083d0afe6 --- /dev/null +++ b/tests/scripts/nuke-aws.sh @@ -0,0 +1,28 @@ +#!/bin/bash + +set -ex + +nuke_aws() { + cloud-nuke --version + cloud-nuke aws \ + --log-level debug \ + --resource-type s3 \ + --resource-type vpc \ + --resource-type ebs \ + --resource-type eip \ + --resource-type ec2 \ + --resource-type efs \ + --resource-type asg \ + --resource-type ekscluster \ + --resource-type nat-gateway \ + --resource-type iam-role \ + --resource-type elb \ + --region us-west-2 \ + --log-level debug \ + --config tests/common/cloud-nuke-config.yml --dry-run +} + +nuke_aws || true +echo "Trying again to nuke to be sure" +nuke_aws +echo "Done"