Skip to content

Uses CloudFront + Lambda@Edge to route subdomains to a folder inside a bucket

Notifications You must be signed in to change notification settings

MarceloAlves/pr-preview-deploy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Serverless PR Preview Deploy

Uses CloudFront + Lambda@Edge to route subdomains to a folder inside a bucket.

Setup

Prerequisites

  • A domain name

Setup

  1. Add the domain to Route 53
  2. Start the creation of a public certification using Certificate Manager in the US-EAST-1 region. Use the wildcard version as the domain name (*.example.com) and the full domain as an additional name (example.com). For domain verification, allow Certificate Manager to set up Route 53.
  3. Update the following files:
    • serverless.yml
      • Line 3: Set the name of the S3 bucket
      • Lines 63 & 64: Update the aliases to the regular domain and wildcard domain (ex: example.com & *.example.com)
      • Line 66: Update the value to the resource name of the certificate created in step 2
    • handler.js
      • Line 3: Update value to the domain name with prefix of . (ex: .example.com)
      • Line 5: Update the value to the name of the S3 bucket that was set in serverless.yml:3
  4. Run serverless deploy, cross your fingers and grab a beer cause it'll take a while to run.
  5. Update Route 53 to point to the CloudFront distribution

Usage

Using the S3 cli, copy files to a folder in the bucket name you picked in step 3. To view the deployed site, visit https://{site-bucket-name}.{domain}.com

Credits

Adpated from this SO answer with updates for SPA routing and Serverless deploy

About

Uses CloudFront + Lambda@Edge to route subdomains to a folder inside a bucket

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published