Here’s the full list of posts for this series:
Wh
When multiple things resolve to a single endpoint, using a DNS CNAME abstraction will simplify your configuration.
For example, say I have three websites:
foo.mycompany.com
bar.mycompany.com
bas.mycompany.com
And these all need to resolve back to the same AWS ELB endpoint (e.g., elb-blah.amazonaws.com
).
I have two options here:
- Create 3 CNAME records and map each to elb.blah.amazonaws.com
foo.mycompany.com
–>elb.blah.amazonaws.com
bar.mycompany.com
–>elb.blah.amazonaws.com
bas.mycompany.com
–>elb.blah.amazonaws.com
OR
- Create an abstraction CNAME, and map the records to that
gw.mycompany.com
–>elb.blah.amazonaws.com
foo.mycompany.com
–>gw.mycompany.com
bar.mycompany.com
–>gw.mycompany.com
bas.mycompany.com
–>gw.mycompany.com
Now why would I want to do this? I essentially created four records instead of 3… Preparation.
DNS records can change and evolve constantly. Say, for example, that you moved from AWS to Google Cloud (e.g., glb-blah.cloud.google.com
); you’d need to update all three records:
foo.mycompany.com
–>glb-blah.cloud.google.com
bar.mycompany.com
–>glb-blah.cloud.google.com
bas.mycompany.com
–>glb-blah.cloud.google.com
However, if you used CNAME abstraction, you would only need to update the record for gw and point to the new GCP endpoint:
gw.mycompany.com
–>glb-blah.cloud.google.com
But what if They don’t all point to the same endpoints now? Simple, just create another CNAME abstraction and update foo,bar,bas to point to the necessary endpoints.
foo.mycompany.com
–>glb-blah.cloud.google.com
bar.mycompany.com
–>glb-blah.cloud.google.com
bas.mycompany.com
–>glb-blah.cloud.google.com
Should I always abstract things? Not all the time. Here are the considerations I evaluate whenever I’m looking at this:
- Will > 1 thing ever point to this?
- Is the possibility that this will change non-zero?
In most cases, things are never permanent, so in most cases I use URL abstractions to simplify my life down the line.