2

您好我尝试执行以下命令以将全局二级索引添加到现有表:

aws dynamodb update-table \
    --region eu-west-1 \
    --endpoint-url http://127.0.0.1:8000/ \
    --table-name ssib_dev_assetsTable \
    --attribute-definitions AttributeName=AssetGroup,AttributeType=S \
    --global-secondary-index-updates  \
    Create="{IndexName=gsi_group,KeySchema=[{AttributeName=AssetGroup,KeyType=HASH}],Projection={ProjectionType=ALL}}" \
    --provisioned-throughput ReadCapacityUnits=10,WriteCapacityUnits=10 \

+ 或 - 10 秒后,我得到以下响应,没有任何明确的错误消息。我使用https://hub.docker.com/r/cnadiminti/dynamodb-local/来模拟我的数据库。

调用 UpdateTable 操作时发生错误(InternalFailure)(达到最大重试次数:9):由于未知错误、异常或失败,请求处理失败。

4

1 回答 1

4

该参数--global-secondary-index-updates应该是一个有效的 JSON 字符串,但您的情况并非如此。它还缺少一个强制密钥,ProvisionedThroughput.

https://docs.aws.amazon.com/cli/latest/reference/dynamodb/update-table.html

开始:

aws dynamodb update-table \
    --region eu-west-1 \
    --endpoint-url http://127.0.0.1:8000 \
    --table-name ssib_dev_assetsTable \
    --attribute-definitions AttributeName=AssetGroup,AttributeType=S \
    --global-secondary-index-updates '[{"Create":{"IndexName":"gsi_group","KeySchema":[{"AttributeName":"AssetGroup","KeyType":"HASH"}],"Projection":{"ProjectionType":"ALL"},"ProvisionedThroughput":{"ReadCapacityUnits":5,"WriteCapacityUnits":5}}}]'

By the way, you should probably use the official image instead of some image by some random user docker user: https://hub.docker.com/r/amazon/dynamodb-local/

于 2020-08-25T16:39:34.510 回答