Skip to content

AWS CDK React app template using S3 and CloudFront

License

Notifications You must be signed in to change notification settings

sikleber/aws-cdk-react-template

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

aws-cdk-react-template

This project is a template for creating a React application hosted on AWS and deployed using the AWS Cloud Development Kit (CDK). It consists of two TypeScript projects using NPM:

Frontend Project

See the frontend package.json for relevant scripts.

Infrastructure Project

See the infrastructure package.json for relevant scripts.

Deploy the infrastructure using the following commands:

npm run deploy -- --profile <profile> --region <region> --context config=dev

The cdk.json file tells the CDK Toolkit how to execute your app.

Infrastructure Overview

Infrastructure

Custom Configuration Settings

The infrastructure/config.ts reads the configuration specified by the --context config=<CONFIG_NAME parameter when deploying the CDK stack. Defined settings can be passed to underlying constructs.

GitHub Actions CI/CD

This project uses GitHub Actions for CI/CD. Two workflows are defined in the .github/workflows directory:

  • ci.yml - runs on every push to any branch except main
  • cd.yml - runs on every push to main and deploys the application to AWS

To use the CD workflow and deploy the application an AWS account, you need to set up the following secrets in your GitHub repository:

  • AWS_ACCESS_KEY_ID
  • AWS_SECRET_ACCESS_KEY

Before the first deployment, you may need to bootstrap the CDK in your AWS account (see: Bootstrapping).:

npx cdk bootstrap aws://<account>/<region>