Skip to content

Commit

Permalink
chore: Delete orphan R53 record in functional-tests workflow (#78)
Browse files Browse the repository at this point in the history
  • Loading branch information
CuriousLearner authored Sep 13, 2024
1 parent 4d91b6a commit cb92f21
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions .github/workflows/functional_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ jobs:
-
name: Build
run: go build

-
name: AppPack Account
run: |
Expand Down Expand Up @@ -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: |
Expand Down

0 comments on commit cb92f21

Please sign in to comment.