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

Serverless project to deploy a CDN for hosting static assets in private S3 buckets

License

Notifications You must be signed in to change notification settings

smoketurner/serverless-cdn

Repository files navigation

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

About

Serverless project to deploy a CDN for hosting static assets in private S3 buckets

Topics

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published