The main domain record (foosite.com
), unlike whatever.foosite.com
cannot be answered as CNAME, only A or AAAA. If I remember it properly, it is by RFC.
Solution: e.g. amazon inventedhas tricky way. The key here is not 'the main record cannot have cname record' but 'the main record cannot be answered as cname record'. They made their own record type - alias.
The difference between cname and alias is that when a dns client queries a site with cname - it receives a reference to another domain and have to resolve it too, whilst for alias record the dns server itself resolves the result and returns the IP - as it should be by RFC.
TL;DR Use Route53 at amazon or something like that.