diff --git a/.github/workflows/ami-release-nix.yml b/.github/workflows/ami-release-nix.yml index d500af738..3b5430dd1 100644 --- a/.github/workflows/ami-release-nix.yml +++ b/.github/workflows/ami-release-nix.yml @@ -129,6 +129,11 @@ jobs: SLACK_MESSAGE: 'Building Postgres AMI failed' SLACK_FOOTER: '' + - name: Cleanup resources on build cancellation + if: ${{ always() }} + run: | + aws ec2 describe-instances --filters "Name=tag:packerExecutionId,Values=${GITHUB_RUN_ID}" --query "Reservations[].Instances[].InstanceId" --output text | xargs -n 1 -I {} aws ec2 terminate-instances --instance-ids {} + - name: Cleanup resources on build cancellation if: ${{ cancelled() }} run: |