Ends in
00
days
00
hrs
00
mins
00
secs
ENROLL NOW

Get $4 OFF in AWS Solutions Architect & Data Engineer Associate Practice Exams for $10.99 each ONLY!

Leveraging Amazon CloudFront with S3 and Route 53 for Subdomain Configuration

Amazon S3 and Route 53, both provided by AWS, offer a comprehensive solution for managing and deploying web content. Route 53 allows you to create alias records that direct to the website endpoint of your S3 bucket. Meanwhile, Amazon S3 is a robust service for hosting static websites. These services, when used together, provide a powerful toolset for web content management. However, there’s a key requirement when using these services together: the bucket name in S3 must be the same as the domain or subdomain hosted on Route 53. This is because when a request comes to Route 53, it redirects the request to the S3 bucket with the same name. If the bucket name doesn’t match the domain or subdomain, Route 53 will not be able to route the traffic correctly.

This requirement can pose a challenge if you want to use a different bucket name, domain, or subdomain. Reasons could include organizational naming conventions, managing multiple environments like development, staging, and production, categorizing different types of content into different buckets, or catering to users from various geographical locations with different buckets in different regions to reduce latency. A different bucket name can also add a layer of security by making it harder for malicious actors to guess your bucket name. However, there can be implications, such as the need for more complex routing rules or certain features not being available. But don’t worry, there’s a solution to this.

The process involves setting up an S3 static website, creating a CloudFront distribution that points to the S3 bucket, and configuring Route 53 to point your domain or subdomain to the CloudFront distribution. This setup allows us to have an S3 bucket name that is different from the domain or subdomain.

Before we proceed, ensure that your S3 static website configuration is already set up. If you haven’t configured your S3 static website yet, you can follow these steps to do so.

The Role of Amazon CloudFront

Amazon CloudFront is a content delivery network (CDN) offered by AWS. It can be used in conjunction with S3 and Route 53 to bypass the aforementioned requirement.

Here’s how it works:

  1. Create a CloudFront Distribution: You can create a CloudFront distribution and point it to the S3 bucket. This allows CloudFront to fetch content from your S3 bucket and deliver it to your users.

      • Go to CloudFront -> Distributions -> Click the “Create Distribution” button.
      • Origin domain: Click “Use website endpoint” after selecting your S3 bucket.

        Leveraging Amazon CloudFront with S3 and Route 53 for Subdomain Configuration

      • Web Application Firewall (WAF): In this example, choose “Do not enable security protections”.
      • Alternate domain name (CNAME): Enter the subdomain that you would like to use.

        Leveraging Amazon CloudFront with S3 and Route 53 for Subdomain Configuration

  2. Tutorials dojo strip

 

      • To add an alternate domain name (CNAME) to a CloudFront distribution, ensure to attach a trusted certificate that validates your authorization to use the domain name.

        Leveraging Amazon CloudFront with S3 and Route 53 for Subdomain Configuration

      • If you don’t need to change any settings, you can just stick with the default configurations.
      • To create a distribution, simply click on the button labeled “Create Distribution” located at the bottom of the page.
      • Note: It may take some time to create your CloudFront Distribution.
  1. Create a Record Set in Route 53: In Route 53, you create a record set that points your domain or subdomain to the CloudFront distribution. This way, the S3 bucket name does not need to match the domain or subdomain.

      • Go to Route53 -> Hosted zones -> YOUR_DOMAIN -> Create record
      • Record name: Enter the subdomain that you would like to use (Make sure that the subdomain you have specified matches the one on the CloudFront Distribution.)
      • Record type: Choose “A – Routes traffic to an IPV4 address and some AWS resources”
      • Enable the Alias toggle.
      • Choose endpoint: Choose “Alias to CloudFront Distribution”
      • Choose region: Select the region that you have configured for your S3 static website.
      • Choose distribution: When you click on the search box, it will automatically detect your CloudFront Distribution.
      • Routing policy: Choose “Simple routing”.

        Leveraging Amazon CloudFront with S3 and Route 53 for Subdomain Configuration

      • To create a record, simply click on the button labeled “Create records” located at the bottom of the page.
      • Finally, verify in your browser that the newly created subdomain is properly pointing to your S3 static website.
      • You can also verify your domain by visiting https://www.whatsmydns.net/

A CloudFront distribution can point to either an Amazon S3 bucket directly or an S3 bucket website endpoint. Here are some differences between the two:

  1. S3 Bucket Directly (REST API endpoint): When you configure your CloudFront distribution to use an S3 bucket directly, it accesses the bucket using the S3 REST API endpoint. This allows you to use all S3 features, including server-side encryption and S3 Transfer Acceleration.

  2. S3 Bucket Website Endpoint: When you configure your CloudFront distribution to use an S3 bucket website endpoint, it accesses the bucket using the S3 website hosting endpoint. This allows you to use S3 website hosting features. However, it does not support all S3 features.

By using CloudFront, you can have an S3 bucket name that is different from your domain or subdomain. However, there’s one important thing to note: an S3 bucket that’s configured as a website endpoint doesn’t support SSL/TLS. This means that when a user connects to CloudFront, they use a secure HTTPS connection. However, the connection between CloudFront and S3 is done over HTTP. To ensure that the entire connection, including the part between CloudFront and S3, is secured with SSL/TLS encryption, you can use the S3 REST API endpoint as the CloudFront origin.

To sum up, although there are some prerequisites to follow when using Amazon S3 and Route 53 in conjunction, services such as Amazon CloudFront offer the versatility required to fulfill your unique needs. This combination of services not only ensures secure and efficient content delivery but also provides a robust infrastructure for your static website hosting needs.

Get $4 OFF in AWS Solutions Architect & Data Engineer Associate Practice Exams for $10.99 ONLY!

Tutorials Dojo portal

Be Inspired and Mentored with Cloud Career Journeys!

Tutorials Dojo portal

Enroll Now – Our Azure Certification Exam Reviewers

azure reviewers tutorials dojo

Enroll Now – Our Google Cloud Certification Exam Reviewers

AWS Exam Readiness Courses

Tutorials Dojo Exam Study Guide eBooks

tutorials dojo study guide eBook

FREE AWS Exam Readiness Digital Courses

Subscribe to our YouTube Channel

Tutorials Dojo YouTube Channel

FREE Intro to Cloud Computing for Beginners

FREE AWS, Azure, GCP Practice Test Samplers

Recent Posts

Written by: Nestor Mayagma Jr.

Nestor is a web developer and member of the AWS Community Builder. He continuously strives to expand his knowledge and expertise in AWS to foster personal and professional growth. He also shares his insights with the community through numerous AWS blogs, highlighting his commitment to Cloud Computing technology. In his leisure time, he indulges in playing FPS and other online games.

AWS, Azure, and GCP Certifications are consistently among the top-paying IT certifications in the world, considering that most companies have now shifted to the cloud. Earn over $150,000 per year with an AWS, Azure, or GCP certification!

Follow us on LinkedIn, YouTube, Facebook, or join our Slack study group. More importantly, answer as many practice exams as you can to help increase your chances of passing your certification exams on your first try!

View Our AWS, Azure, and GCP Exam Reviewers Check out our FREE courses

Our Community

~98%
passing rate
Around 95-98% of our students pass the AWS Certification exams after training with our courses.
200k+
students
Over 200k enrollees choose Tutorials Dojo in preparing for their AWS Certification exams.
~4.8
ratings
Our courses are highly rated by our enrollees from all over the world.

What our students say about us?