gpt4 book ai didi

amazon-dynamodb - 从 CLI 创建全局二级索引

转载 作者:行者123 更新时间:2023-12-01 00:20:45 25 4
gpt4 key购买 nike

我希望有人可以帮助我使用 Dynamo CLI 语法。

我一直无法从 CLI 创建全局二级索引。

我在索引之前的脚本按预期工作:

aws dynamodb create-table \
--table-name a.b.c \
--attribute-definitions \
AttributeName=TransactionID,AttributeType=S \
--key-schema \
AttributeName=TransactionID,KeyType=HASH \
--provisioned-throughput\
ReadCapacityUnits=5,WriteCapacityUnits=5 \
--endpoint-url $DATABASE_ENDPOINT_URL

添加索引时,出现错误:
aws dynamodb create-table \
--table-name a.b.c \
--attribute-definitions \
AttributeName=TransactionID,AttributeType=S \
AttributeName=BatchID,AttributeType=S \
AttributeName=TransactionStatus,AttributeType=S \
--key-schema \
AttributeName=TransactionID,KeyType=HASH \
--global-secondary-indexes IndexName=a.b.indexName,\
KeySchema=["{AttributeName=BatchID,KeyType=HASH}","{AttributeName=TransactionStatus,KeyType=RANGE}"],\
Projection="{ProjectionType=KEYS_ONLY}",\
ProvisionedThroughput="{ReadCapacityUnits=5,WriteCapacityUnits=5}"\
--provisioned-throughput\
ReadCapacityUnits=5,WriteCapacityUnits=5 \
--endpoint-url $DATABASE_ENDPOINT_URL

我收到的错误是:
Error parsing parameter '--global-secondary-indexes': Expected: '<second>', received: '<none>' for input: IndexName=a.b.indexName,

这似乎直接来自示例。我也尝试使用基于其他问题的一些示例的文件,但也没有运气。

最佳答案

将所有内容放在一行上修复了它。

这有效:

aws dynamodb create-table \
--table-name a.b.c \
--attribute-definitions \
AttributeName=TransactionID,AttributeType=S \
AttributeName=BatchID,AttributeType=S \
AttributeName=TransactionStatus,AttributeType=S \
--key-schema \
AttributeName=TransactionID,KeyType=HASH \
--global-secondary-indexes IndexName=a.b.indexName,KeySchema=["{AttributeName=BatchID,KeyType=HASH}","{AttributeName=TransactionStatus,KeyType=RANGE}"],Projection="{ProjectionType=KEYS_ONLY}",ProvisionedThroughput="{ReadCapacityUnits=5,WriteCapacityUnits=5}"\
--provisioned-throughput\
ReadCapacityUnits=5,WriteCapacityUnits=5 \
--endpoint-url $DATABASE_ENDPOINT_URL

关于amazon-dynamodb - 从 CLI 创建全局二级索引,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48909818/

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