gpt4 book ai didi

amazon-web-services - 使用 SAM 模板创建 DynamoDB 表时出现错误

转载 作者:行者123 更新时间:2023-12-03 07:33:26 33 4
gpt4 key购买 nike

我想使用 SAM 模板创建 DynamoDB 表,并且我是 SAM 模板的新手。我对哈希范围没有更好的了解这是我的 DynamoDB 模板部分

  MyDynamoDBTable:
Type: AWS::DynamoDB::Table
DeletionPolicy: Retain
Properties:
TableName: customerInformations
AttributeDefinitions:
- AttributeName: phoneNumber
AttributeType: S
- AttributeName: firstName
AttributeType: S
- AttributeName: lastName
AttributeType: S
- AttributeName: address
AttributeType: S
- AttributeName: email
AttributeType: S
KeySchema:
- AttributeName: phoneNumber
KeyType: HASH
- AttributeName: firstName
KeyType: RANGE
- AttributeName: lastName
KeyType: RANGE
- AttributeName: address
KeyType: RANGE
- AttributeName: email
KeyType: RANGE

这是我在创建表时收到的错误代码。

CREATE_FAILED       AWS::DynamoDB::Table        MyDynamoDBTable             Resource handler retur                                                               message: "1 validation
error detected: Value '[K
eySchemaElement(attribute
Name=phoneNumber,
keyType=HASH), KeySchemaE
lement(attributeName=firs
tName, keyType=RANGE), Ke
ySchemaElement(attributeN
ame=lastName,
keyType=RANGE), KeySchema
Element(attributeName=add
ress, keyType=RANGE), Key
SchemaElement(attributeNa
me=email,
keyType=RANGE)]' at
'keySchema' failed to
satisfy constraint:
Member must have length
less than or equal to 2
(Service: DynamoDb,
Status Code: 400, Request
ID: 2SRKQ9ETQUEGIC6GO0HHT
70JIJVV4KQNSO5AEMVJF66Q9A
SUAAJG)" (RequestToken: b
9b143a9-c010-f185-4811-93
a3b91f2e52,
HandlerErrorCode:
InvalidRequest)

任何帮助将不胜感激。

最佳答案

您正在尝试创建一个包含 4 个范围键的表。 Dynamo 仅支持 1 个 Partition 和 1 个 Range key。您应该看看documentation在继续之前。

示例解决方案:

  MyDynamoDBTable:
Type: AWS::DynamoDB::Table
DeletionPolicy: Retain
Properties:
TableName: customerInformations
AttributeDefinitions:
- AttributeName: phoneNumber
AttributeType: S
- AttributeName: firstName
AttributeType: S
KeySchema:
- AttributeName: phoneNumber
KeyType: HASH
- AttributeName: firstName
KeyType: RANGE

关于amazon-web-services - 使用 SAM 模板创建 DynamoDB 表时出现错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/73442346/

33 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com