Trong bước này, chúng ta sẽ tạo một bảng DynamoDB mới bằng cách sử dụng mẫu SAM.
Mở template.yaml trong mã nguồn bạn đã tải xuống trước đó.
Thêm tham số sau để định nghĩa tên bảng cho FCAJOrdersTable.
orderTable:
Type: String
Default: OrdersTable

Thêm khối tài nguyên sau để tạo bảng DynamoDB FCAJOrdersTable.
FCAJOrdersTable:
Type: AWS::DynamoDB::Table
Properties:
TableName: !Ref orderTable
BillingMode: PAY_PER_REQUEST
AttributeDefinitions:
- AttributeName: id
AttributeType: S
- AttributeName: book_id
AttributeType: S
KeySchema:
- AttributeName: id
KeyType: HASH
- AttributeName: book_id
KeyType: RANGE

Chạy các lệnh dưới đây để xác thực và build mẫu SAM.
sam validate
sam build

Triển khai stack đã cập nhật.
sam deploy

Chờ CloudFormation stack hoàn thành việc tạo tài nguyên FCAJOrdersTable.

Mở AWS DynamoDB console để xác minh bảng OrdersTable đã được tạo thành công.
