我希望有人可以帮助我使用 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
Run Code Online (Sandbox Code Playgroud)
添加索引时,出现错误:
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
Run Code Online (Sandbox Code Playgroud)
我收到的错误是:
Error parsing parameter '--global-secondary-indexes': Expected: '<second>', received: '<none>' for input: IndexName=a.b.indexName,
Run Code Online (Sandbox Code Playgroud)
这似乎直接来自示例。我也尝试使用基于其他问题的一些示例的文件,但也没有运气。
将所有内容放在一行上修复了它。
这有效:
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
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
982 次 |
| 最近记录: |