AWS DynamoDB Local 使用 awscli 添加全局二级索引
AWS DynamoDB Local add global secondary index using awscli
您好,我尝试执行以下命令以将全局二级索引添加到现有 table:
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/ 来模拟我的数据库。
An error occurred (InternalFailure) when calling the UpdateTable
operation (reached max retries: 9): The request processing has failed
because of an unknown error, exception or failure.
参数 --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/
您好,我尝试执行以下命令以将全局二级索引添加到现有 table:
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/ 来模拟我的数据库。
An error occurred (InternalFailure) when calling the UpdateTable operation (reached max retries: 9): The request processing has failed because of an unknown error, exception or failure.
参数 --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/