I'm trying to set a CNAME on Cloudflare to point to an Amazon API Gateway endpoint. The CNAME is for use when referring to one of my subdomains. The gateway in turn points to the IP of a server on DigitalOcean. I am very new to Amazon web services and would appreciate if someone could give me an overview of the correct configuration for the DNS, Amazon Gateway and Cloudfront (which I think is needed to expose the gateway to DNS servers external to Amazon). Any help would be much appreciated.
UPDATE
I've been going at this for a while now and not making much progress. Does anyone have an idea if this is a viable approach or how else it might be done?
UPDATE2
I thought I needed to add the CNAME record to cloudFlare and just ended up in a redirect loop, observed by:
curl -L -i -v https://sub.mydomain.com/
There are several reasons why it doens't work to simply point Cloudflare at your API Gateway domain and call it a day:
api.yourdomain.com
belongs to your API.https
, but the certificate that it uses is only valid for the default domain.There is a solution, however. Here are the steps that I followed when I recently set this up:
us-east-1
region, even if your API is located in a different region. If you are prompted for the certificate chain you can copy it from here.That's it. Enjoy your new highly available API served from your custom domain!