Open template.yaml file in fcj-book-shop folder.
Copy the following scripts into that file.
booksTableName:
Type: String
Default: Books
BooksTable:
Type: AWS::DynamoDB::Table
Properties:
TableName: !Ref booksTableName
BillingMode: PAY_PER_REQUEST
AttributeDefinitions:
- AttributeName: id
AttributeType: S
- AttributeName: rv_id
AttributeType: N
- AttributeName: name
AttributeType: S
KeySchema:
- AttributeName: id
KeyType: HASH
- AttributeName: rv_id
KeyType: RANGE
LocalSecondaryIndexes:
- IndexName: name-index
KeySchema:
- AttributeName: id
KeyType: HASH
- AttributeName: name
KeyType: RANGE
Projection:
ProjectionType: ALL
Run the following command to deploy SAM.
sam build
sam validate
sam deploy
Back to DynamoDB console. At Tables page.
To add data to the table, you can download the below file. Then, open file and replace all AWS-REGION with the region that create S3 bucket - book-image-resize-shop-by-myself, such as: us-east-1
.