| Did this page help you? Yes No Tell us about it... |
A CNAME record is an entry in a DNS table that lets you alias one fully qualified
domain name to another. For example, if you owned www.beagles.com and
beagles.dogs.com, you could create the following CNAME record that
would specify www.beagles.com as an alias for
beagles.dogs.com.
www.beagles.com CNAME beagles.dogs.com
A CNAME is useful because it lets you choose a domain name for your links instead of the domain name CloudFront provides you. Download and streaming distributions support CNAMEs.
![]() | Important |
|---|---|
You must be the owner of any domain name that you specify as an alias of your distribution's domain name. |
You create a distribution, and CloudFront returns
d604721fxaaqy9.cloudfront.net as the distribution's domain name. The link
you would create to your object called images/image.jpg would
be http://d604721fxaaqy9.cloudfront.net/images/image.jpg.
However, you want your links to use example.com instead of the
cloudfront.net domain name that CloudFront provided. So you want
the link to images/image.jpg to be
http://example.com/images/image.jpg instead of
http://d604721fxaaqy9.cloudfront.net/images/image.jpg.
![]() | Note |
|---|---|
CloudFront doesn't support CNAMEs with HTTPS. If content is requested over HTTPS using CNAMEs, your end users' browsers will display the warning: This page contains both secure and non-secure items. To prevent this message from appearing, don't use CNAMEs with CloudFront HTTPS distributions. |
The following figure and table describe the process for setting up a CNAME alias so you can use your own domain name in your links instead of your distribution's CloudFront domain name.

Process for Setting Up a CNAME Alias
|
1 |
Update your distribution's configuration to include the
CNAME alias (using the If you're adding another CNAME alias to a distribution that already has one, see Multiple CNAME Aliases. For information about distribution configuration and updating a distribution, see Updating a Distribution's Configuration, and go to DistributionConfig Complex Type in the Amazon CloudFront API Reference. For more information about streaming distributions, go to StreamingDistributionConfig Complex Type in the Amazon CloudFront API Reference. | |||
|
2 |
Confirm your update in task 1 is fully deployed. The update is fully deployed after the distribution's
status returns to | |||
|
3 |
Create a CNAME record in the DNS system to establish the alias between your domain name and the CloudFront domain name for your distribution. The exact procedure for configuring DNS depends on your DNS server or DNS provider and is beyond the scope of this document.
| |||
|
4 |
Confirm in the DNS system that the CNAME record points to your distribution's domain name. Use a DNS tool like dig (for information about dig, go to http://www.kloth.net/services/dig.php). The following shows an example dig request on a domain name called images.yourdomain.com, and the relevant part of the response. [prompt]> dig images.yourdomain.com
; <<> DiG 9.3.3rc2 <<> images.yourdomain.com
;; global options: printcmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 15917
;; flags: qr rd ra; QUERY: 1, ANSWER: 9, AUTHORITY: 2, ADDITIONAL: 0
;; QUESTION SECTION:
;images.yourdomain.com. IN A
;; ANSWER SECTION:
The line in the Answer Section shows the CNAME alias between
the domain name images.yourdomain.com and the CloudFront
distribution domain name d604721fxaaqy9.cloudfront.net. The CNAME record
for your domain name is set up correctly if the name on the
right side of | |||
|
5 |
Test the CNAME alias. Create some test links that use your domain name in the URL instead of the distribution's CloudFront domain name. Test those links to confirm your content is being served correctly with the CNAME alias. | |||
|
6 |
Go live with the CNAME alias. Substitute your domain name for the distribution's CloudFront domain name in your live links to objects. |
You can use more than one CNAME alias with a distribution. For example, you could
have alias1.example.com and alias2.example.com both
associated with your distribution's domain name. You can have up to 10 CNAME aliases
per distribution. You can associate a particular CNAME alias with only one
distribution.
![]() | Important |
|---|---|
When adding an additional CNAME alias to a distribution that already has
one, make sure to include the original CNAME alias in the
|
In a distribution's configuration, the lack of a CNAME element is not
equivalent to an empty CNAME element (<CNAME/>). If you
don't want the distribution to have a CNAME, then don't include a CNAME
element when you create the distribution or update its configuration. If you do,
CloudFront returns a MalformedXML error (for more information about
errors, go to Errors in the
Amazon CloudFront API Reference). The following table shows a correct and
incorrect configuration object for a distribution with no CNAMEs. For more
information about the configuration object, go to DistributionConfig Complex
Type in the Amazon CloudFront API Reference.
|
Correct |
<?xml version="1.0" encoding="UTF-8"?>
<DistributionConfig xmlns="http://cloudfront.amazonaws.com/doc/2010-11-01/">
<S3Origin>
<DNSName>mybucket.s3.amazonaws.com</DNSName>
</S3Origin>
<CallerReference>20091130090000</CallerReference>
<Comment>My comments</Comment>
<Enabled>true</Enabled>
</DistributionConfig>
|
|
Incorrect |
<?xml version="1.0" encoding="UTF-8"?>
<DistributionConfig xmlns="http://cloudfront.amazonaws.com/doc/2010-11-01/">
<S3Origin>
<DNSName>mybucket.s3.amazonaws.com</DNSName>
</S3Origin>
<CallerReference>20091130090000</CallerReference>
<CNAME/>
<Comment>My comments</Comment>
<Enabled>true</Enabled>
</DistributionConfig>
|
To remove a CNAME from a distribution, remove the corresponding CNAME
element and update the configuration. For information about updating a
distribution's configuration, see Updating a Distribution's Configuration.