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

Latest commit

 

History

History
35 lines (22 loc) · 1.47 KB

25-deploy-a-site-with-https-support-behind-a-cdn-with-cdk.md

File metadata and controls

35 lines (22 loc) · 1.47 KB

Deploy a site with HTTPS support behind a CDN with CDK

📹 Video

We want our website to be secure and served on https (and not on http) - let's fix that.

Also, in the previous lesson, we had to type out the three steps for deploying our frontend:

  • Creating a bucket
  • Creating a bucket deployment
  • Creating a CloudFormation output

We can solve both things by using CDK-SPA-Deploy! It can be used to deploy an SPA (Single Page Application), written in reactJS (or Angular/Vue) to aws behind SSL (meaning https) on CloudFront.

To add it, run:

  • npm install --save cdk-spa-deploy

🤔 Cloudfront is Amazon's CDN (Content Delivery Network).

CDN Illustration

Import it to the stack file:

  • import { SPADeploy } from "cdk-spa-deploy";

Then comment out (or remove) the three sections that we wrote in the last time lesson and replace them with:

new SPADeploy(this, "WebsiteDeployment").createSiteWithCloudfront({
    indexDoc: "index.html",
    websiteFolder: "../frontend/build"
});

🤔 You can check out the source code here.