Skip to content

Commit

Permalink
fixing the e2e test for terraform (#205)
Browse files Browse the repository at this point in the history
  • Loading branch information
edgarsilva948 authored Jun 19, 2024
1 parent 0e35a1e commit 4e623ea
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 8 deletions.
21 changes: 21 additions & 0 deletions .github/scripts/e2e-delete-log-groups.py
Original file line number Diff line number Diff line change
@@ -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()
22 changes: 14 additions & 8 deletions .github/workflows/e2e-parallel-full.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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: |
Expand All @@ -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
Expand Down

0 comments on commit 4e623ea

Please sign in to comment.