Created
October 30, 2019 15:00
-
-
Save rhopp/91dab4840c07c99dc55b7c430ad41aa0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
CLUSTER_NAME=<cluster_name - for example 'rhopp-qa'> | |
HOSTED_ZONE_ID=Z3URY6TWQ91KVV | |
# aws route53 list-resource-record-sets --hosted-zone-id ${HOSTED_ZONE_ID} --output json > allRecordSets.json | |
jq ".ResourceRecordSets[] | select(.Name | contains(\"api.${CLUSTER_NAME}.devcluster.openshift.com\"))" allRecordSets.json > apiRecordSet.json | |
jq ".ResourceRecordSets[] | select(.Name | contains(\"\\\\052.apps.${CLUSTER_NAME}.devcluster.openshift.com\"))" allRecordSets.json > appsRecordSet.json | |
API_DNS_NAME=$(jq .AliasTarget.DNSName apiRecordSet.json) | |
APPS_DNS_NAME=$(jq .AliasTarget.DNSName appsRecordSet.json) | |
API_HOSTED_ZONE_ID=$(jq .AliasTarget.HostedZoneId apiRecordSet.json) | |
APPS_HOSTED_ZONE_ID=$(jq .AliasTarget.HostedZoneId appsRecordSet.json) | |
cat <<EOF > apiRequest.json | |
{ | |
"Comment": "Deleting ${CLUSTER_NAME} api recordset", | |
"Changes": [ | |
{ | |
"Action": "DELETE", | |
"ResourceRecordSet": { | |
"Name": "api.${CLUSTER_NAME}.devcluster.openshift.com.", | |
"Type": "A", | |
"AliasTarget": { | |
"DNSName": "${API_DNS_NAME}", | |
"HostedZoneId": "${API_HOSTED_ZONE_ID}", | |
"EvaluateTargetHealth": false | |
} | |
} | |
} | |
] | |
} | |
EOF | |
cat <<EOF > appsRequest.json | |
{ | |
"Comment": "Deleting ${CLUSTER_NAME} apps recordset", | |
"Changes": [ | |
{ | |
"Action": "DELETE", | |
"ResourceRecordSet": { | |
"Name": "*.apps.${CLUSTER_NAME}.devcluster.openshift.com.", | |
"Type": "A", | |
"AliasTarget": { | |
"DNSName": "${APPS_DNS_NAME}", | |
"HostedZoneId": "${APPS_HOSTED_ZONE_ID}", | |
"EvaluateTargetHealth": false | |
} | |
} | |
} | |
] | |
} | |
EOF |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment