gpt4 book ai didi

amazon-web-services - 在 DynamoDB 表 : AttributeDefinitions is not specified 上创建索引时出错

转载 作者:行者123 更新时间:2023-12-04 17:50:47 31 4
gpt4 key购买 nike

我正在尝试使用 AWS 命令​​行界面向现有 DynamoDB 表添加全局二级索引。

根据 documentation ,我正在使用这个更新表命令:

aws dynamodb update-table --table-name messages --global-secondary-index-updates file://input.json

我的 input.json 文件有索引的定义:
[
{
"Create": {
"IndexName": "FeedIndex",
"KeySchema": [
{
"AttributeName": "feed",
"KeyType": "HASH"
},
{
"AttributeName": "status",
"KeyType": "RANGE"
}
],
"Projection": {
"ProjectionType": "INCLUDE",
"NonKeyAttributes": ["message"]
},
"ProvisionedThroughput": {
"ReadCapacityUnits": 5,
"WriteCapacityUnits": 5
}
}
}
]

当我运行命令时,我收到此错误:
An error occurred (ValidationException) when calling the UpdateTable operation: One or more parameter values were invalid: AttributeDefinitions is not specified for index: FeedIndex

为什么我会收到这个错误?在我看来,我已经指定了添加索引所需的所有文档。最初创建表时指定了 AttributeDefinitions;我原以为将索引添加到现有表不需要这些定义。

最佳答案

attribute-definitions错过了。您需要定义属于 KeySchema 的属性。 .

aws dynamodb update-table --table-name messages --attribute-definitions AttributeName=feed,AttributeType=S AttributeName=status,AttributeType=S --global-secondary-index-updates file://input.json

关于amazon-web-services - 在 DynamoDB 表 : AttributeDefinitions is not specified 上创建索引时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45086215/

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