Skip to content
This repository has been archived by the owner on Feb 17, 2020. It is now read-only.

Latest commit

 

History

History
60 lines (44 loc) · 2.42 KB

README.md

File metadata and controls

60 lines (44 loc) · 2.42 KB

ARCHIVED - please use https://github.com/smoketurner/sam-cdn instead

serverless-cdn

serverless MIT licensed build status

Serverless project that deploys a content delivery network (CDN) using AWS CloudFront for static assets hosted in a private S3 bucket.

This project creates the following resources:

  • AWS::CertificateManager::Certificate - *.<domain> SSL certificate
  • AWS::CloudFront::Distribution - [http|https]://<domain> distribution
  • AWS::CloudFront::Distribution - [http|https]://www.<domain> redirect distribution
  • AWS::CloudFront::CloudFrontOriginAccessIdentity
  • AWS::Route53::RecordSet - <domain> IPv4 DNS entry
  • AWS::Route53::RecordSet - <domain> IPv6 DNS entry
  • AWS::Route53::RecordSet - www.<domain> IPv4 DNS entry
  • AWS::Route53::RecordSet - www.<domain> IPv6 DNS entry
  • AWS::S3::Bucket - private access log bucket
  • AWS::S3::Bucket - private static asset bucket
  • AWS::S3::Bucket - private bucket to redirect requests to https://<domain>
  • AWS::S3::BucketPolicy - only allow CloudFront to access static asset bucket
  • AWS::Lambda::Function - Lambda@Edge function for single page applications to redirect requests to /index.html
  • AWS::Lambda::Function - Lambda@Edge function to add various web security HTTP response headers

Installation

git clone https://github.com/smoketurner/serverless-cdn.git
cd serverless-cdn
npm install

Run Tests

npm test

Deploy

npm run deploy
npm run client-deploy # deploy sample hello world from dist folder

You can either put your static assets into the dist folder and run npm run client-deploy to upload them to the S3 bucket, or upload files directly to the <domain> S3 bucket. Route53 and CloudFront will take care of any redirections and content serving for you.

Removal

npm run remove

References