Giter Club home page Giter Club logo

nodejs-aws-shop-react's Introduction

React-shop-cloudfront

This is frontend starter project for nodejs-aws mentoring program. It uses the following technologies:

NPM Scripts

  • start - Starts the project in dev mode with mocked API on local environment.

  • build - Builds the project for production in dist folder.

  • preview - Starts the project in production mode on local environment.

  • test, test:ui, test:coverage - Runs tests in console, in browser or with coverage.

  • lint, prettier - Runs linting and formatting for all files in src folder.

AWS CDK Stack

AWS CDK code is written in Typescript (located at ./cdk) and compiled using ESBuild: patched AWS CDK Workshop is used as a template taking into account that Lambda functions will be developed as ESM in the next tasks.

Important Notes

Legacy Entries

There are discrepancies between AWS Console and AWS CDK API in handling some CloudFront configuration provided by default:

  1. AWS Console encourages use of Origin access control settings (recommended) but AWS CDK uses Legacy access identities while configuring CloudFront origin;

  2. AWS Console encourages use of Cache policy and origin request policy (recommended) but AWS CDK uses Legacy cache settings while configuring CloudFront default behavior.

To address both issues AWS CDK template is updated manually (please see changes for CloudFront origin and CloudFront behavior)

NPM scripts

  • cdk - Builds/runs AWS CDK project (no need to call manually, it's used in cdk.json config file);

  • cdk:diff - Runs AWS CDK diff command to illustrate how local template is different to a deployed one (in order to use a user's profile the script needs to be run as npm run cdk:diff -- --profile={profile_name})

  • cdk:deploy - Runs AWS CDK deploy command to deploy stack (in order to use a user's profile the script needs to be run as npm run cdk:deploy -- --profile={profile_name})

  • cdk:destroy - Runs AWS CDK destroy command to destroy previously deployed stack (in order to use a user's profile the script needs to be run as npm run cdk:destroy -- --profile={profile_name})

Deployment

In order to deploy application stack with AWS CDK one needs to run the following commands:

  1. npm run build
  2. npm run cdk:deploy (in order to use a user's profile the script needs to be run as npm run cdk:deploy -- --profile={profile_name})

AWS CDK Outputs

To simplify verification of deployed stack corresponding outputs are added to the stack as can be seen at the image below (Both outputs are provided below as well to simplify cross-check verification).

image

CloudFront

Static website is served via CloudFront distribution available at https://du5vmcpwti84k.cloudfront.net/

S3 Bucket Url

CloudFront uses S3 Bucket as the origin at http://rs-aws-static-site.s3-website.eu-central-1.amazonaws.com/ (not available directly, S3 bucket's policy allows CloudFront distribution to get objects)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.