ARCHIVED - please use https://github.com/smoketurner/sam-cdn instead
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 certificateAWS::CloudFront::Distribution
-[http|https]://<domain>
distributionAWS::CloudFront::Distribution
-[http|https]://www.<domain>
redirect distributionAWS::CloudFront::CloudFrontOriginAccessIdentity
AWS::Route53::RecordSet
-<domain>
IPv4 DNS entryAWS::Route53::RecordSet
-<domain>
IPv6 DNS entryAWS::Route53::RecordSet
-www.<domain>
IPv4 DNS entryAWS::Route53::RecordSet
-www.<domain>
IPv6 DNS entryAWS::S3::Bucket
- private access log bucketAWS::S3::Bucket
- private static asset bucketAWS::S3::Bucket
- private bucket to redirect requests tohttps://<domain>
AWS::S3::BucketPolicy
- only allow CloudFront to access static asset bucketAWS::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
git clone https://github.com/smoketurner/serverless-cdn.git
cd serverless-cdn
npm install
npm test
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.
npm run remove