AWS CloudFront in 3 Minutes
Tags: aws, cdn, cloudfront, cloudskills
Published: 2021-02-03 14:42:45

## Overview

AWS [CloudFront](https://aws.amazon.com/cloudfront/) is a [Content Delivery Network (CDN)](https://www.akamai.com/us/en/cdn/what-is-a-cdn.jsp). That means that it can provide better performance by combating latency. It achieves this by caching data at [Edge Locations](https://wa.aws.amazon.com/wat.concept.edge-location.en.html), which are closer to the user than the origin may be.

CloudFront follows the popular pay-as-you-go [pricing](https://aws.amazon.com/cloudfront/pricing/). Although, it's pricing model is closer to serverless than to EC2 as you won't pay for idle time. Additionally, you can drastically reduce origin costs because the data is cached and not fetched everytime. 

## Features

* [Access Control](https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/SecurityAndPrivateContent.html)
![Access Control](https://dev-to-uploads.s3.amazonaws.com/i/6scol6bh1czrw0k8newe.png)
* [Edge Computing](https://aws.amazon.com/lambda/edge/)
![Lambda@Edge](https://dev-to-uploads.s3.amazonaws.com/i/2bxfqeakuejlsjf26fl6.png)
* [Fast Change Propagation](https://aws.amazon.com/blogs/networking-and-content-delivery/slashing-cloudfront-change-propagation-times-in-2020-recent-changes-and-looking-forward/)
* [Geo Restriction](https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/georestrictions.html)
* Global Edge Network
![Global Edge Network](https://dev-to-uploads.s3.amazonaws.com/i/xxg2n8gp38qccfdzr9ry.png)
* [Invalidation Control (Cache Purging)](https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/Invalidation.html)
* [IPv6](https://aws.amazon.com/about-aws/whats-new/2016/10/ipv6-support-for-cloudfront-waf-and-s3-transfer-acceleration/)
* [Logging including Real Time](https://aws.amazon.com/cloudfront/faqs/?nc=sn&loc=5&dn=2#Logging_and_reporting)
* [Streaming](https://aws.amazon.com/cloudfront/streaming/)
![Video On-Demand (VOD)](https://dev-to-uploads.s3.amazonaws.com/i/5aui5t4ipyez8m18byv5.png)
* [WebSockets](https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/distribution-working-with.websockets.html)

## Integrations

* [ACM](https://aws.amazon.com/cloudfront/custom-ssl-domains/) for SSL/TLS Certificates
* [CloudWatch](https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/reports-and-monitoring.html) for Monitoring and Logging
* [Lambda](https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/lambda-at-the-edge.html) for Edge Compute
* [Route53](https://docs.aws.amazon.com/Route53/latest/DeveloperGuide/routing-to-cloudfront-distribution.html) for Routing
![CloudFront Routing](https://dev-to-uploads.s3.amazonaws.com/i/t2z3eyjrcsz9lw8rn0vi.PNG)
* [Shield](https://aws.amazon.com/shield/) for DDoS Protection
* [WAF](https://docs.aws.amazon.com/waf/latest/developerguide/cloudfront-features.html) for Custom Firewall Controls

## Origins

Most commonly [S3](https://aws.amazon.com/s3/) is used as the origin to set up a simple static website with ease. Actually CloudFront supports custom origins as an HTTP server, which leads to options like: [API Gateway](https://aws.amazon.com/api-gateway), [EC2](https://aws.amazon.com/ec2/), and even on-prem.

Still you're not limited to a single origin. In a machine learning movie recommendation website, [wheelerrecommends](https://wheelerrecommends.com/), I created I am using CloudFront with multiple origins.

I wrote another [blog](https://dev.to/wheelerswebsites/my-october-cloud-guru-challenge-experience-5ecg) on that website if you'd like to learn more.

![Wheeler Recommends Architecture](https://dev-to-uploads.s3.amazonaws.com/i/oytmdxbhbwsrz0mjvsr8.png)

> https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/DownloadDistS3AndCustomOrigins.html

## Resources

* [Best Practices for DDoS Resiliency](https://docs.aws.amazon.com/whitepapers/latest/aws-best-practices-ddos-resiliency/aws-best-practices-ddos-resiliency.pdf)
* [CloudFormation Documentation](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/AWS_CloudFront.html)
* [CloudFront Documentation](https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/Introduction.html)
* [Getting Started](https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/GettingStarted.html)
* [Open Guide](https://github.com/open-guides/og-aws#cloudfront)