Use custom domain (apex) in AWS API Gateway

最后都变了- 提交于 2019-12-24 10:39:47

问题


I would like to use a custom domain for an AWS API Gateway endpoint, this would allow me to use mydomain.com instead of https://xxxxxxxx.execute-api.eu-west-1.amazonaws.com/v1.

I managed to add the custom domain in API Gateway but now I need to set the DNS of the domain (this domain is NOT managed by Route53).

As far as I understand I should set an A record but I don't have any IP provided by the cloudfront distribution and it cannot be a CNAME because I want to bind a domain (apex) not a subdomain.

How could I set the domain, without transfering DNS management to Route 53 ?

Thank you


回答1:


This is not possible. Route 53 has special capabilities that allow you to alias the apex of a domain to another AWS resource, without using a CNAME record -- which is not valid at the apex of a domain.

You don't have to transfer your domain registration to Route 53 -- that's optional -- but you do have to create a hosted zone and configure your existing registrar to use the nameservers Route 53 assigns to your new hosted zone as your authoritative name servers. Transferring the registration itself, or not, does not impact performance -- queries are neither slower nor faster when your domain name host and your registrar are two different providers or not.




回答2:


I struggled quite a bit with the same problem and actually found a solution in this gist. As the gist suggests, you need to create a "Hosted Zone" in Route 53 (you don't need to transfer the domain or anything like that).

Once you create the zone, NS records are created in it. They look something like this:

ns-1208.awsdns-23.org.
ns-2016.awsdns-60.co.uk. 
ns-642.awsdns-16.net. 
ns-243.awsdns-30.com.

Just copy the NS (name server) records and replace the ones for your domain name at your DNS provider's control panel. The NS records can be used to point DNS management from other domain registrar to AWS Route 53

This would take a while to update (around 1-2 days). You can go on and create an alias record in this hosted zone to point your apex domain to your API gateway (or a similar AWS service which doesn't provide a static IP).



来源:https://stackoverflow.com/questions/48402465/use-custom-domain-apex-in-aws-api-gateway

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!