在无服务器yml文件中创建DynamoDB表



我将在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。有可能创建这样一个表吗?我不能用任何索引中都不包含的属性创建表吗?

必须在属性定义中包含键。

UsersTable:
Type: AWS::DynamoDB::Table
Properties:
TableName: users
AttributeDefinitions:
- AttributeName: user_id
AttributeType: S
- AttributeName: bitwage_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

最新更新