A demo for the AWS CDK using API Gateway, Lambda, CloudFront, S3 and React
Inside frontEndContent/react-demo folder
- npm install
- npm run build
You will need an AWS account, if the AWS account is not configured locally run aws configure
In the root folder
- npm install
- cdk bootstrap or
- cdk bootstrap aws://YOUR_ACCOUNT_NUMBER/DESIRED_AWS_REGION
In the root folder
- cdk deploy
- note the output API endpoint in the console, you will need it in the next step
- note the CloudFront distribution domain name, this is the app's URL
Copy the API endpoint URL either from the terminal output or the AWS Console API Gateway section Inside frontEndContent/react-demo folder replace "to_be_added_after_the_first_stack_deploy": REACT_APP_API_URL=to_be_added_after_the_first_stack_deploy with the actual endpoint; the format is: https://xxxxxxxxx.execute-api.aws-region.amazonaws.com/prod note the missing / at the end
In the root folder
- cdk deploy
- go to AWS Console -> CloudFront and copy the distribution domain name which is an URL it has this format: https://xxxxxxxxxxxx.cloudfront.net
- put that in the browser and use the website
The cdk.json
file tells the CDK Toolkit how to execute your app.
npm run build
compile typescript to jsnpm run watch
watch for changes and compilenpm run test
perform the jest unit testscdk deploy
deploy this stack to your default AWS account/regioncdk diff
compare deployed stack with current statecdk synth
emits the synthesized CloudFormation template
An AWS account is needed to run this stack. The AWS account should be configured locally. See https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-configure.html for configuring an account
It also helps if the CDK CLI is installed globally. An AWS Getting started page can be found here: https://docs.aws.amazon.com/cdk/v2/guide/getting_started.html
Learn more about this demo from the accompanying article: https://medium.com/@cdohotaru/an-aws-cdk-demo-with-api-gateway-lambda-react-and-a-pipeline-to-rule-them-all-afef4795982b