Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/smoketurner/sam-cdn
AWS project to deploy a CDN for hosting static assets in private S3 buckets
https://github.com/smoketurner/sam-cdn
aws cloudfront lambda-edge route53 s3 sam serverless
Last synced: 7 days ago
JSON representation
AWS project to deploy a CDN for hosting static assets in private S3 buckets
- Host: GitHub
- URL: https://github.com/smoketurner/sam-cdn
- Owner: smoketurner
- License: mit
- Created: 2019-12-17T20:49:28.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2023-12-11T12:08:28.000Z (11 months ago)
- Last Synced: 2024-03-26T03:59:07.300Z (8 months ago)
- Topics: aws, cloudfront, lambda-edge, route53, s3, sam, serverless
- Homepage: https://serverlessrepo.aws.amazon.com/applications/arn:aws:serverlessrepo:us-east-1:860114833029:applications~cloudfront-cdn
- Size: 502 KB
- Stars: 19
- Watchers: 3
- Forks: 7
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
- Security: SECURITY.md
Awesome Lists containing this project
README
[![MIT licensed](https://img.shields.io/badge/license-MIT-blue.svg)](https://raw.githubusercontent.com/smoketurner/sam-cdn/master/LICENSE)
[![build status](https://github.com/smoketurner/sam-cdn/workflows/Node%20CI/badge.svg)](https://github.com/smoketurner/sam-cdn/actions?query=workflow%3A%22Node+CI%22)
[![Launch Stack](https://s3.amazonaws.com/cloudformation-examples/cloudformation-launch-stack.png)](https://console.aws.amazon.com/lambda/home?#/create/app?applicationId=arn:aws:serverlessrepo:us-east-1:860114833029:applications/cloudfront-cdn)A 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` - `*.` SSL certificate
- `AWS::CloudFront::Distribution` - `[http|https]://` distribution
- `AWS::CloudFront::Distribution` - `[http|https]://www.` redirect distribution
- `AWS::CloudFront::CloudFrontOriginAccessIdentity`
- `AWS::Route53::RecordSet` - `` IPv4 DNS entry
- `AWS::Route53::RecordSet` - `` IPv6 DNS entry
- `AWS::Route53::RecordSet` - `www.` IPv4 DNS entry
- `AWS::Route53::RecordSet` - `www.` 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://`
- `AWS::S3::BucketPolicy` - only allow CloudFront to access static asset bucket
- `AWS::CloudFront::Function` - CloudFront Function for single page applications to redirect requests to `/index.html`
- `AWS::CloudFront::Function` - CloudFront Function to add various web security HTTP response headers## Installation
```
git clone https://github.com/smoketurner/sam-cdn.git
cd sam-cdn
npm install
```## Deploy
```
npm run build
npm run deploy
```You can upload your static assets into the S3 bucket and Route53 and CloudFront will take care of any redirections and content serving for you.
## References
- https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/example-function-add-index.html
- https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/example-function-add-security-headers.html
- https://www.awsadvent.com/2018/12/03/vanquishing-cors-with-cloudfront-and-lambdaedge/
- https://medium.com/faun/hardening-the-http-security-headers-with-aws-lambda-edge-and-cloudfront-2e2da1ae4d83