diff --git a/.github/workflows/functional_tests.yml b/.github/workflows/functional_tests.yml index 890aef5..76be3ab 100644 --- a/.github/workflows/functional_tests.yml +++ b/.github/workflows/functional_tests.yml @@ -23,6 +23,7 @@ jobs: - name: Build run: go build + - name: AppPack Account run: | @@ -113,6 +114,50 @@ jobs: env: AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + + - name: Check and Delete CNAME Record + if: always() + run: | + hosted_zone_id="Z05906472T84V7X7Q6UDY" + record_name="_5b8b09a8917e1fbb8c6aead5121fb550.testclusters.apppack.io" + + echo "Checking if CNAME record exists ..." + # Check if the CNAME record exists + record_value=$(aws route53 list-resource-record-sets --hosted-zone-id $hosted_zone_id \ + --query "ResourceRecordSets[?Name == '$record_name.']" \ + --output text) + + if [[ -n "$record_value" ]]; then + echo "CNAME record exists, deleting..." + + # Extract the actual value of the CNAME record to use in the deletion + cname_value=$(aws route53 list-resource-record-sets --hosted-zone-id $hosted_zone_id \ + --query "ResourceRecordSets[?Name == '$record_name.'].ResourceRecords[0].Value" \ + --output text) + + # Delete the CNAME record + aws route53 change-resource-record-sets --hosted-zone-id "$hosted_zone_id" \ + --change-batch "{ + \"Changes\": [{ + \"Action\": \"DELETE\", + \"ResourceRecordSet\": { + \"Name\": \"$record_name\", + \"Type\": \"CNAME\", + \"TTL\": 300, + \"ResourceRecords\": [{\"Value\": \"$cname_value\"}] + } + }] + }" + + echo "CNAME record deleted successfully." + else + echo "CNAME record does not exist, skipping deletion." + fi + env: + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + AWS_DEFAULT_REGION: us-east-1 + - name: Destroy region run: |