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

CNAME records don't work #9

Open
compilingEntropy opened this issue Oct 7, 2021 · 0 comments · May be fixed by #10
Open

CNAME records don't work #9

compilingEntropy opened this issue Oct 7, 2021 · 0 comments · May be fixed by #10

Comments

@compilingEntropy
Copy link
Contributor

An issue exists with the gathering of the private IP when the record is a CNAME instead of an A record. For an A record, you might see a response to the aws route53 list-resource-record-sets call like this:

[
    "10.10.4.80"
]

That's fine, and we assume (in the python json parsing step) there will only be one entry returned. For a cname record, this is not the case, and the return from that call looks more like this:

[
    "service01.test",
    "10.10.4.80",
    "service.test"
]

The above would be an example output for a case where the records were set up as follows:

service.test => CNAME => service01.test
service01.test => A => 10.10.4.80

Obviously, assuming that only one record can be returned is the wrong approach. In the absence of good AWS documentation on the topic, I propose that in the case where multiple records are returned we should look for whichever returned record most looks like an IP address (using pattern matching).

PRIVATE_IP="$(aws route53 list-resource-record-sets --hosted-zone-id $HOSTED_ZONE_ID --query 'ResourceRecordSets[?contains(Name,`'$SERVER'`)].ResourceRecords[].Value' --profile $AWS_PROFILE --output json 2> /dev/null | python -c 'import sys, json; print json.load(sys.stdin)[0]' 2> /dev/null)"

PRIVATE_IP="$(aws route53 list-resource-record-sets --hosted-zone-id $HOSTED_ZONE_ID --query 'ResourceRecordSets[?contains(Name,`'$SERVER'`)].ResourceRecords[].Value' --profile $AWS_PROFILE --output json 2> /dev/null | python -c 'import sys, json; print json.load(sys.stdin)[0]' 2> /dev/null)"

@compilingEntropy compilingEntropy linked a pull request Jan 20, 2023 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant