diff --git a/.github/scripts/e2e-delete-log-groups.py b/.github/scripts/e2e-delete-log-groups.py new file mode 100644 index 00000000..ff408b59 --- /dev/null +++ b/.github/scripts/e2e-delete-log-groups.py @@ -0,0 +1,21 @@ +import os +import boto3 + +REGION = os.environ.get('AWS_DEFAULT_REGION', 'us-east-1') +CLIENT = boto3.client('logs', region_name=REGION) + +def delete_log_groups(): + """Delete all log groups in the region that start with `/aws/eks/`""" + response = CLIENT.describe_log_groups( + logGroupNamePrefix='/aws/eks/', + limit=50 + ) + + for log_group in [log.get('logGroupName') for log in response.get('logGroups', {})]: + CLIENT.delete_log_group( + logGroupName=log_group + ) + + +if __name__ == '__main__': + delete_log_groups() \ No newline at end of file diff --git a/.github/workflows/e2e-parallel-full.yml b/.github/workflows/e2e-parallel-full.yml index b16d25e1..b96b4e11 100644 --- a/.github/workflows/e2e-parallel-full.yml +++ b/.github/workflows/e2e-parallel-full.yml @@ -46,6 +46,7 @@ jobs: pip3 install boto3 python3 .github/scripts/e2e-delete-sgs.py python3 .github/scripts/e2e-delete-lbs.py + python3 .github/scripts/e2e-delete-log-groups.py deploy: name: Run e2e test @@ -93,14 +94,9 @@ jobs: working-directory: ${{ matrix.example_path }} run: | terraform init -upgrade=true - terraform apply -target="module.vpc" -no-color -input=false -auto-approve - terraform apply -target="module.eks" -no-color -input=false -auto-approve - terraform apply -target="module.eks_blueprints_addons" -no-color -input=false -auto-approve - terraform apply -target="module.crossplane" -no-color -input=false -auto-approve - terraform apply -target="module.gatekeeper" -no-color -input=false -auto-approve - terraform apply -no-color -input=false -auto-approve - - - name: Terraform Destroy + terraform apply -no-color -auto-approve + + - name: Terraform Destroy Addons if: github.event.inputs.TFDestroy == 'true' && (steps.apply.outcome == 'success' || steps.apply.outcome == 'failure') working-directory: ${{ matrix.example_path }} run: | @@ -109,6 +105,16 @@ jobs: terraform destroy -target="module.gatekeeper" -no-color -auto-approve terraform destroy -target="module.eks_blueprints_addons" -no-color -auto-approve terraform destroy -target="module.eks" -no-color -auto-approve + + - name: Ensure load balancers and sgs are removed + run: | + pip3 install boto3 + python3 .github/scripts/e2e-delete-sgs.py + python3 .github/scripts/e2e-delete-lbs.py + python3 .github/scripts/e2e-delete-log-groups.py + + - name: Terraform Destroy Resources + run: | terraform destroy -target="module.vpc" -no-color -auto-approve terraform destroy -no-color -auto-approve