从CLI创建全局二级索引

4
我希望有人可以帮助我理解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,

看起来这似乎是从示例中直接复制的。我还尝试过使用一些其他问题的示例文件,但仍然没有成功。


我犯了同样的错误。我将 "" 后面的空格去掉后修复了它。 - user5515
1个回答

5
把所有内容放在一行上就解决了。
这样做是有效的:
```html

这是一个示例。

```
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

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接