【发布时间】:2020-08-03 00:39:19
【问题描述】:
我将在 yml 文件中创建表。当我写如下时,首先它是成功创建的。
UsersTable:
Type: AWS::DynamoDB::Table
Properties:
TableName: users
AttributeDefinitions:
- AttributeName: user_id
AttributeType: S
KeySchema:
- AttributeName: user_id
KeyType: HASH
ProvisionedThroughput:
ReadCapacityUnits: 5
WriteCapacityUnits: 5
但我需要更多的属性,所以我改变如下。
UsersTable:
Type: AWS::DynamoDB::Table
Properties:
TableName: users
AttributeDefinitions:
- AttributeName: user_id
AttributeType: S
- AttributeName: email_lower_case
AttributeType: S
- AttributeName: book_id
AttributeType: S
- AttributeName: book_amount
AttributeType: S
KeySchema:
- AttributeName: user_id
KeyType: HASH
ProvisionedThroughput:
ReadCapacityUnits: 5
WriteCapacityUnits: 5
但它显示这样的错误。
An error occurred: UsersTable - One or more parameter values were invalid: Number of attributes in KeySchema does not exactly match number of attributes defined in AttributeDefinitions
我不想使用其他 KeySchema。是否可以创建这样的表? 我不能用不包含在任何索引中的属性创建表吗?
【问题讨论】:
-
除了哈希和范围键之外,您没有定义任何属性。您的程序可以在插入或更新期间创建任意数量的属性。
标签: node.js amazon-web-services amazon-dynamodb yaml