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 các đoạn mã sau đây để tạo bảng FcjOrdersTable.
orderTable:
Type: String
Default: OrdersTable
FcjOrdersTable:
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.
sam build
sam validate
sam deploy
Mở AWS DynamoDB console để kiểm tra.