Skip to content

CNAME records don't work #9

@compilingEntropy

Description

@compilingEntropy

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)"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions