Preparing

Before doing the main content of this workshop, we prepare the services and data for the application.

  1. Download the source code of the SAM project below.

    📥 fcaj-book-shop-000085.zip

  2. Unzip and go to the root directory of fcaj-book-shop project. Run the below commands.

Ensure you have the AWS CLI and SAM CLI installed on your machine, configure AWS credentials before running the commands.

```bash
sam build
sam validate
sam deploy --guided
```
  1. Enter the following content. Leave as default.

    • Stack Name []: fcaj-book-store
    • AWS Region []: us-east-1
    • Confirm changes before deploy [Y/n]: y
    • Allow SAM CLI IAM role creation [Y/n]: y
    • Disable rollback [y/N]: n
    • Save arguments to configuration file [Y/n]: y

    SAM deploy guided - enter parameters

    • Review the CloudFormation changeset and confirm deployment.

    CloudFormation changeset preview

    • After successful creation, record the value of the ApiUrl outputs.

    Stack created successfully

    • Go to API Gateway console, click on fcaj-serverless-api.

    API Gateway console

    • Click Stages → select staging stage → record the Invoke URL.

    API Gateway Invoke URL

  2. To add data to the table, you can download the file below:

    📥 dynamoDB.json

  3. Open this file, replace all <AWS-REGION> with the region where you created the S3 book-image-resize-shop-by-myself bucket, for example: us-east-1.

    Open dynamoDB.json and replace AWS-REGION

  4. Run the following command in the directory where you save the dynamoDB.json

    aws dynamodb batch-write-item --request-items file://dynamoDB.json
    

    Run batch-write-item command