DEV Community

Cover image for Amazon CloudFront with continuous integration and delivery pipeline
Bugra Kilic for AWS Community Builders

Posted on

Amazon CloudFront with continuous integration and delivery pipeline

Amazon CloudFront is one of AWS Networking and Content Delivery (N&CD) products which delivers content to the edge locations with low latency and high speed. End users, in other words, visitors all around the globe can reach the content fast and securely. So it is a high end Content Delivery Network (CDN) with more than 410 Points of Presence (PoP) located globally by AWS.

This blog post aims to explain how continuous integration and continuous delivery (CI/CD) works on CloudFront. For more information about creating CF distributions and integration with S3, please see this guide.

Below architecture shows a simple flow from end users to S3 origin bucket by using a CloudFront distribution.

Simple working concept of CloudFront and S3
Simple working concept of CloudFront and S3.

So what is a CI/CD pipeline? 

It is an agile delivery workflow focusing on frequent and reliable development. It stands for Continuous Integration and Continuous Delivery. And the pipeline is the whole process from building to deployment. All process consist of four stages: Build, Test, Deliver and Deploy.

CI/CD pipeline is important for technical teams and companies to reduce time-consuming jobs, such as iterative manual tasks or unpredictable human caused errors.

Then, what is the challenge of CI/CD for CDN? 

CDN changes are relatively slow. Because there is some configuration for content caching mechanism which understands the change of the origin content and distributes this change to all edge locations. And it takes some time to effect. Of course this configuration can be set properly to reduce the caching period, but this is not the only challenge. Besides that, a little misconfiguration can cause an outage to the end users. Therefore any kind of change action should be taken more carefully to prevent a possible outage. If the edge users cannot enter the front door, it is more likely to experience a global or regional service cut.

What is the solution then?

AWS recently published a blog post to announce a new way to safely validate CDN changes. It is not a brand new concept in the server world, but it will be used widely soon for sure. 

The solution include a different type of distributions associated with the production distribution. It's called staging distribution. Now developers can safely test and validate all changes on staging part without concerning any sort of problematic issue.

Staging distribution in action.
Staging distribution in action.

Traffic can be shifted to the staging by using two main continuous deployment policies. 

  • Weight-based 

User has the control to specify the percentage of the user requests which will be routed to staging distribution. Change testing can start small but then increase easily. The change can be applied widely. 

  • Header-based 

Only user requests with a specific HTTP header will be routed to staging distribution. This configuration is more useful when some local tests are needs to be done in a small-scaled testing environment.

Since all already understood that the solution includes a way with two methods to develop software without any kind of interruption. So the main difference here is to safely test, integrate and validate a new load to the origin distribution. 

Last words 

CI/CD usage and latest update on CloudFront have been explained briefly in this post. You can learn to create a staging distribution with the help of this step by step guide written on the same official blog post. Thank you for reading.

Top comments (0)