Before getting to the main content of this workshop, we need to reset the web application using AWS SAM.
Download the source code below and extract it to your working directory.
Before deploying, retrieve the Cognito App Client ID and Cognito App Client Secret.

Open a terminal in the extracted source code folder and run the following commands.
Ensure you have the AWS CLI and SAM CLI installed and configured with valid AWS credentials before running the commands.
sam validate
sam build
sam deploy --guided

When prompted, enter the following values. Leave others as default.
fcaj-book-shopap-southeast-1fcaj-book-shop-by-tranvixyyny
Review the CloudFormation changeset that lists all resources to be created, then confirm the deployment.

Wait for CloudFormation to finish creating all resources. The deployment is complete when the stack status shows CREATE_COMPLETE.

Clone the FCAJ Workshop Serverless frontend repository.
git clone https://github.com/tranvix0910/FCAJ_Workshop-Serverless.git
cd FCAJ_Workshop-Serverless
Install the project dependencies.
npm install --force
If npm install (without --force) fails due to dependency conflicts such as ERESOLVE overriding peer dependency, use npm install --force to force the installation even though some packages are outdated.

Build the front-end application.
npm run build

Upload the build folder to your S3 bucket.
aws s3 cp build s3://fcaj-book-shop-by-tranvix --recursive
Replace fcaj-book-shop-by-tranvix with the name of the S3 bucket you created during the sam deploy step.

Verify that all files were uploaded successfully by checking the Objects tab of your S3 bucket.

In the S3 bucket Properties tab, scroll down to Static website hosting and copy the Bucket website endpoint URL.


Open the endpoint URL in your browser to confirm the application is running correctly.

We have successfully rebuilt and deployed the web application. We are now ready to proceed with the main workshop content.