dnscontrol icon indicating copy to clipboard operation
dnscontrol copied to clipboard

Route53 Traffic policy record

Open perrfect opened this issue 5 years ago • 13 comments

Hi. On Route53 i have Traffic policy for geolocation for a domain. Can i manage this type of record through dnscontrol?

perrfect avatar Jan 17 '20 10:01 perrfect

Hi!

DNSControl doesn't currently manage that. We'd be open to PRs that add that feature.

I believe that Terraform supports that kind of thing.

tlimoncelli avatar Jan 17 '20 13:01 tlimoncelli

Thank you

perrfect avatar Jan 17 '20 14:01 perrfect

@perrfect Did you find a solution for this?

truthdoug avatar Dec 13 '21 18:12 truthdoug

@perrfect Did you find a solution for this?

Hello. No, i didn't find the solution(

perrfect avatar Dec 14 '21 11:12 perrfect

Adding some notes here because I got curious about this again.

For this example, traffic from the EU goes to a cloudfront distribution and other traffic goes to an S3 bucket.

Using the aws command line, I grabbed all json data for my zone like this: aws route53 list-resource-record-sets --hosted-zone-id /hostedzone/redacted

The geolocated records look like this:

{
    "ResourceRecordSets": [
        {
            "Name": "example.org.",
            "Type": "A",
            "SetIdentifier": "default-configuration-geolocation",
            "GeoLocation": {
                "CountryCode": "*"
            },
            "AliasTarget": {
                "HostedZoneId": "redacted1",
                "DNSName": "s3-example-us-east-1.amazonaws.com.",
                "EvaluateTargetHealth": false
            }
        },
        {
            "Name": "example.org.",
            "Type": "A",
            "SetIdentifier": "europe-record",
            "GeoLocation": {
                "ContinentCode": "EU"
            },
            "AliasTarget": {
                "HostedZoneId": "redacted2",
                "DNSName": "example.cloudfront.net.",
                "EvaluateTargetHealth": false
            }
        }
    ]
}

Using dnscontrol get-zones -format=js, the resulting lines currently look like this:

R53_ALIAS('@', 'A', 's3-example-us-east-1.amazonaws.com.', R53_ZONE('redacted1')),
R53_ALIAS('@', 'A', 'example.cloudfront.net.', R53_ZONE('redacted2')),

From a UX point of view, my first thought was that the geolocation could be added as an argument to R53_ALIAS() but that won't work because other types of records (A, CNAME, etc) can also have geolocation variants.

I've looked a bit at providers/route53/route53Provider.go but I'm not sure where to start with this.

Is there a similar provider-specific feature that might be a good model for implementing this?

truthdoug avatar May 04 '23 20:05 truthdoug

Ah! That json is very enlightening!

My recommendation is to add something like: R53_GEOZONE() that would accept a dictionary with all the various parameters. That would be stored in the metadata for that record for use by the provider.

R53_ALIAS('@', 'A', 's3-example-us-east-1.amazonaws.com.', R53_ZONE('redacted1'),
          R53_GEO( {
            "SetIdentifier": "default-configuration-geolocation",
            "GeoLocation": {
                "CountryCode": "*"
            },
            "AliasTarget": {
                "HostedZoneId": "redacted1",
                "DNSName": "s3-example-us-east-1.amazonaws.com.",
                "EvaluateTargetHealth": false
            }
       }),
R53_ALIAS('@', 'A', 'example.cloudfront.net.', R53_ZONE('redacted2'),
       R53_GEO( {
            "SetIdentifier": "europe-record",
            "GeoLocation": {
                "ContinentCode": "EU"
            },
            "AliasTarget": {
                "HostedZoneId": "redacted2",
                "DNSName": "example.cloudfront.net.",
                "EvaluateTargetHealth": false
            }
       }),

It isn't pretty, but ... we could add a R53_GEO_BUILDER() function later.

I lack time to write this kind of feature (Stack isn't giving me time to work on features that Stack doesn't use). However I'd be glad to walk you through it. It would be relatively straight forward. The integration tests take out a lot of the guess-work.

tlimoncelli avatar May 04 '23 20:05 tlimoncelli

I'm intrigued by the idea of writing support for this with your guidance, @tlimoncelli

... in the interim, I just read about the new IGNORE feature. Am I correct in thinking that this might be a good stop gap solution? By using IGNORE() on the records that have the Route53 geolocation designation, I could then manage the other records on this zone using dnscontrol.

Does that sound right?

truthdoug avatar Jun 02 '23 20:06 truthdoug

Yes! That should work! Try putting an IGNORE() in that matches any records you create manually (i.e. clickops)

tlimoncelli avatar Jun 03 '23 10:06 tlimoncelli