Instead of assigning an Elastic IP to an EC2 instance, can I just CNAME a URL to the instance's public DNS name?
Yes, you can do that however the instances public DNS name will change any time an instance is started up. The best options are to either use the elastic IP (EIP) or work behind an elastic load balancer (ELB). Both options would be better to point a DNS entry to and would be able to remain the same on instance restarts. You would use a CNAME entry for ELB and you could use either an A or CNAME record for the EIP option. The advantage of the ELB option is that you could have multiple EC2 instances behind it giving you greater fault tolerance.
-
When you get an Elastic IP, the Public DNS entry of your EC2 instance will reflect that Elastic IP, e.g. if your Elastic IP is
55.201.201.55
then your Public DNS entryec2-55-201-201-55.us-west-1.compute.amazonaws.com
. So wouldn't it be find to use that as your target? – alexkb Nov 21 '18 at 3:15
You can; but you really should get a elastic IP and map an A record to that, it is a much better solution. It'll be more reliable and result in faster DNS for clients(less lookups)
Yes. Just remember when you're setting up a cname
to an external domain, you need to suffix it with a .