This is frontend starter project for nodejs-aws mentoring program. It uses the following technologies:
- Vite as a project bundler
- React as a frontend framework
- React-router-dom as a routing library
- MUI as a UI framework
- React-query as a data fetching library
- Formik as a form library
- Yup as a validation schema
- Vitest as a test runner
- MSW as an API mocking library
- Eslint as a code linting tool
- Prettier as a code formatting tool
- TypeScript as a type checking tool
-
start
- Starts the project in dev mode with mocked API on local environment. -
build
- Builds the project for production indist
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 insrc
folder.
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.
There are discrepancies between AWS Console and AWS CDK API in handling some CloudFront configuration provided by default:
-
AWS Console encourages use of
Origin access control settings (recommended)
but AWS CDK usesLegacy access identities
while configuring CloudFront origin; -
AWS Console encourages use of
Cache policy and origin request policy (recommended)
but AWS CDK usesLegacy 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)
-
cdk
- Builds/runs AWS CDK project (no need to call manually, it's used incdk.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 asnpm 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 asnpm 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 asnpm run cdk:destroy -- --profile={profile_name}
)
In order to deploy application stack with AWS CDK one needs to run the following commands:
npm run build
npm run cdk:deploy
(in order to use a user's profile the script needs to be run asnpm run cdk:deploy -- --profile={profile_name}
)
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).
Static website is served via CloudFront distribution available at https://du5vmcpwti84k.cloudfront.net/
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)