AWS Basic
- AWS Intro
- Launch EC2 Instance
- Elastic IP
- AWS Target Group
- AWS Application Load Balancer
- AWS Route53
- Amazon Certificate Manager
- Redirect HTTP to HTTPs
- Redirect WWW to Non WWW
- AWS Cloudfront
- Download S3 to Local
- Install Node.js & NPM in EC2
AWS Connection
AWS Wordpress
AWS Deploy App
Exploring AWS Cloudfront
Photo Credit to CodeToFun
🙋 Introduction
Amazon CloudFront, a content delivery network (CDN) service provided by AWS, can significantly enhance the performance, scalability, and global reach of your web application.
In this tutorial, we'll explore how to integrate AWS CloudFront with an existing Application Load Balancer (ALB) that is already serving your domain via a hosted zone.
📚 Prerequisites
Before you proceed, ensure you have the following:
- An AWS account with access to CloudFront and an ALB.
- An ALB configured and serving your domain through a Route 53 hosted zone.
🎨 Create an AWS CloudFront Distribution
Follow the steps below to create a CloudFront Distribution.
Open the AWS Management Console and navigate to the CloudFront service.
Click on the Create a Cloudfront Distribution button.
Photo Credit to CodeToFun
In cloudfront Origin Configuration, choose your application load balancer as the origin domain and Match Viewer as the protocol.
Photo Credit to CodeToFun
Choose TLSv1.2 as Minimum origin SSL protocol.
Photo Credit to CodeToFun
In the Default Cache Behavior section, select your preferred options for Viewer Protocol Policy and Allowed HTTP Methods.
Photo Credit to CodeToFun
In the Cache Key and Origin Request section, choose the recommended setting and select a cache policy of your choice, as shown in the image below.
Photo Credit to CodeToFun
In the Web Application Firewall (WAF) section, choose Enable security protections.
Photo Credit to CodeToFun
In the Settings section, choose Use all edge locations, provide the Alternate domain name (CNAME), and select Custom SSL certificate and cache policy of your choice, as shown in the image below.
Photo Credit to CodeToFun
Keep all suggested settings unchanged, and then press the Create Distribution button.
Photo Credit to CodeToFun
Congratulations! We have created the Cloudfront distribution successfully.
Photo Credit to CodeToFun
🖥️ Monitor and Configure CloudFront
- Return to the CloudFront console.
- Explore the monitoring and logging options available for your distribution.
- Adjust cache settings, behaviors, and other configurations based on your application's requirements.
🔄 Update DNS Records in Route 53
If your domain is currently pointed directly to the ALB, you might need to update the DNS records to point to the CloudFront distribution:
- Navigate to the Route 53 service.
- Select the hosted zone for your domain.
Update the A or CNAME records to point to the CloudFront distribution domain name.
Photo Credit to CodeToFun
🔄 Invalidate Cache (Optional)
If you make changes to your application and want to clear the CloudFront cache:
- Open the CloudFront console.
- Find and select your distribution.
- Go to the "Invalidations" tab.
Click on Create Invalidation and specify the path or paths to invalidate.
Photo Credit to CodeToFun
🎉 Conclusion
Congratulations! You've successfully explored AWS CloudFront and integrated it with your existing Application Load Balancer.
CloudFront adds a layer of optimization, ensuring your web application is delivered with low latency and high availability to users around the world.
Remember to consider best practices for security, pricing, and content management when using CloudFront in a production environment.
👨💻 Join our Community:
Author
For over eight years, I worked as a full-stack web developer. Now, I have chosen my profession as a full-time blogger at codetofun.com.
Buy me a coffee to make codetofun.com free for everyone.
Buy me a Coffee
If you have any doubts regarding this article (Exploring AWS Cloudfront), please comment here. I will help you immediately.