StackExchange / dnscontrol

Infrastructure as code for DNS!
https://dnscontrol.org/
MIT License
3.16k stars 400 forks source link

Support for different types of ALIAS records when using multiple providers. #1394

Open vinoth2710 opened 2 years ago

vinoth2710 commented 2 years ago

I'm trying to do point an ALIAS record to ELB load balancer in both R53 and DNSimple

D("example.com", REG_CHANGEME,
        DnsProvider(R53),
        DnsProvider(DNSIMPLE),
        R53_ALIAS('@', 'A', 'dualstack.staging-elb.us-east-1.elb.amazonaws.com.', R53_ZONE('xxxxx')),
        ALIAS('@', 'dualstack.staging-elb.us-east-1.elb.amazonaws.com.')
)

However I get,

ERROR: domain example.com uses R53_ALIAS records, but DNS provider type DNSIMPLE does not support them
exiting due to validation errors

(or)

ERROR: domain example.com uses ALIAS records, but DNS provider type ROUTE53 does not support them
exiting due to validation errors

If I declare example.com for each provider separately I get executing dnsconfig.js: example.com is declared more than once

I can understand why I'm getting this, but is there a way around(something like conditional records)?

We are trying to make both R53's and DNSimple's name servers authoritative (for failover in case either of them goes down).

tlimoncelli commented 2 years ago

Dnscontrol is designed to create one generic zone that can be pushed to each provider. Therefore a zone can only be pushed to 2 providers if both support all the same records. Changing this would be a big overhaul.

I can offer 3 suggestions:

  1. Use conditionals.

There are conditionals but you'd have to run dnscontrol twice, once for each provider. That's a level of complexity that I don't recommend. However, tips for doing it are here: https://stackexchange.github.io/dnscontrol/cli-variables

  1. Add a feature to support generic aliass.

Add a "generic alias" feature that requires each provider to do the right thing. I'd accept a PR.

  1. Don't use 2 providers.

Ok, that isn't the solution you were hoping for but ... is 2 providers really helping you?

Take a look at your website's uptime. What causes downtime? For me it is things like:

a. A small outage every time I do a software upgrade. (30 seconds; every software push) b. A big outage every time I do a bad software push (1 to 2 hours; about once a month) c. R53 is down. (1-2 hours; about every 2-3 years)

So, if I want to improve my website's uptime the biggest "bang for the buck" would be to fix "a" (use a load balancer and do rolling upgrades) or fix "b" (improve my testing strategy). "c" isn't going to help much. In fact, if I switched to a magical DNS service that had perfect uptime, it wouldn't affect my website much.

If you are looking to improve latency not uptime, you might be able to make an argument for multiple providers. Some do better in different parts of the world. However, in that case I'd recommend a similar analysis: what do your APM metrics say your biggest latency problem is? If you are using ROUTE53 (which is pretty fast, globally), I bet your APM is telling you the problem is elsewhere.

That said... if DNS is the problem, then dual DNS providers is going to help. I would just recommend gathering the metrics before you make the decision to add this kind of complexity.

Tom

vinoth2710 commented 2 years ago

Hey, thanks for the detailed response, I would have a look at the metrics for sure. I tried Split Horizon DNS, it seemed to work pretty well.

D("example.com!r53", REG,
    R53_ALIAS('@', 'A', 'dualstack.staging-elb-1854.us-east-1.elb.amazonaws.com.', R53_ZONE('Z35S')),
    // Other records
)

D("example.com!dnssimple", REG,
    ALIAS('@', 'dualstack.staging-elb-1854.us-east-1.elb.amazonaws.com.'),
    // Other records
)

Is this a possible solution for my case?

tlimoncelli commented 2 years ago

Oh yeah! That isn't what I imagined the split-horizon feature would be used for but it should work just fine. That's very creative!

You'll need to maintain all the other records exactly the same in both places.