Skip to content

AWS CDK definition of infrastructure for Single Page Applications.

Notifications You must be signed in to change notification settings

bogdal/aws-cdk-website

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

aws-cdk-website

It defines the cloud infrastructure dedicated to static Single Page Applications, which uses an S3 bucket for storing the content, CloudFront for distributing the application and Lambda@Edge functions for handling push-state URLs and server-side rendering.

SSR

This Stack provides server-side rendering using https://render-tron.appspot.com/ service by default, but it should also be compatible with other services, such as prerender.io. If you have your own Rendertron instance, just set the URL inside the cdk.json file.

Let's start

Set AWS credentials

$ export AWS_ACCESS_KEY_ID=<access_key>
$ export AWS_SECRET_ACCESS_KEY=<secret_key>

Install dependencies

$ npm i

Bootstrap your AWS environment

Before you can use the AWS CDK you must bootstrap your AWS environment to create the infrastructure that the AWS CDK CLI needs to deploy your Stack.

$ npx cdk bootstrap

Configure your infastructure

Modify the cdk.json file and adjust the context values to your needs:

  ...
  "context": {
    "bucket_name": "<your-bucket-name>",
    "enable_ssr": true,
    "ssr_service_url": "https://render-tron.appspot.com/render/"
  }

Deploy the app stack

$ npm run deploy

Deploy the app content

The command output from the previous step will contain the distribution id value which you should use to deploy your application using AWS CLI.

aws s3 sync dist s3://${BUCKET_NAME} --delete
aws cloudfront create-invalidation --distribution-id ${DISTRIBUTION_ID} --paths "/*"

About

AWS CDK definition of infrastructure for Single Page Applications.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published