Open the DynamoDB console and choose Create table.
Chat-Messages.ConversationId (String).Timestamp (Number). Messages of one conversation are sorted by time.
The second table needs a global secondary index to find the conversations of a user. Create it in CloudShell:
aws dynamodb create-table --table-name Chat-Conversations \
--attribute-definitions AttributeName=ConversationId,AttributeType=S AttributeName=Username,AttributeType=S \
--key-schema AttributeName=ConversationId,KeyType=HASH AttributeName=Username,KeyType=RANGE \
--billing-mode PAY_PER_REQUEST \
--global-secondary-indexes 'IndexName=Username-ConversationId-index,KeySchema=[{AttributeName=Username,KeyType=HASH},{AttributeName=ConversationId,KeyType=RANGE}],Projection={ProjectionType=ALL}' \
--query 'TableDescription.[TableName,TableStatus,GlobalSecondaryIndexes[0].IndexName]' --output text
Chat-Conversations with key ConversationId + Username.Username-ConversationId-index uses the opposite key order. The Lambda code queries it by name.