Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: e2e test for terraform #205

Merged
merged 1 commit into from
Jun 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading