amazon-web-services - AWS DynamoDB Local 使用 awscli 添加全局二级索引

标签 amazon-web-services amazon-dynamodb amazon-dynamodb-local

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

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 字符串,但您的情况并非如此。它还缺少强制性 key 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/

关于amazon-web-services - AWS DynamoDB Local 使用 awscli 添加全局二级索引,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63565400/

相关文章:

node.js - DynamoDB 查询相当于 "WHERE author IN [..]"?

amazon-dynamodb - 什么是DynamoDB number和string数据类型的存储空间

python-3.x - boto3 和 dynamodb-local 的 batch_write 操作极其缓慢

javascript - 多个文件上传到 s3 node.js

amazon-web-services - Amazon S3 + CloudFront 查询特定版本的存储文件

amazon-web-services - 如何在 EC2 上的 docker 内使用 AWS 凭证运行命令?

amazon-web-services - 如何通过特定用户的 Bearer token 访问与 S3 Bucket 连接的 AWS CloudFront(JWT 自定义身份验证)

java - 如何在 Android 中按升序对 DynamoDB Hashkey 进行排序