awscli 在验证属性定义时不考虑全局二级索引

awscli doesn't consider global-secondary-indexes when validating attribute-definitions

我正在尝试在创建 localstack 容器时初始化 dynamodb table。 考虑以下命令:

awslocal dynamodb create-table \
  --debug \
  --table-name Journal \
  --global-secondary-indexes 'IndexName=GetJournalRowsIndex, KeySchema=[{AttributeName=persistence-id, KeyType=HASH},{AttributeName=sequence-nr,KeyType=RANGE}], Projection={ProjectionType=ALL}, ProvisionedThroughput={ReadCapacityUnits=10,WriteCapacityUnits=10}' \
  --global-secondary-indexes 'IndexName=TagsIndex, KeySchema=[{AttributeName=tags,KeyType=HASH}],Projection={ProjectionType=ALL},ProvisionedThroughput={ReadCapacityUnits=10,WriteCapacityUnits=10}' \
  --key-schema \
      AttributeName=pkey,KeyType=HASH \
      AttributeName=skey,KeyType=RANGE \
  --attribute-definitions \
      AttributeName=persistence-id,AttributeType=S \
      AttributeName=pkey,AttributeType=S \
      AttributeName=skey,AttributeType=S \
      AttributeName=sequence-nr,AttributeType=N \
      AttributeName=tags,AttributeType=S \
  --billing-mode PAY_PER_REQUEST

我收到以下错误:

An error occurred (ValidationException) when calling the CreateTable operation: The number of attributes in key schema must match the number of attributesdefined in attribute definitions.

我在 GSI 中使用它们,所以我想知道我在这里做错了什么?

我猜你不能两次指定 global-secondary-indexes 标志。尝试以下

awslocal dynamodb create-table \
  --debug \
  --table-name Journal \
  --global-secondary-indexes "[{\"IndexName\": \"GetJournalRowsIndex\", \"KeySchema\": [{\"AttributeName\": \"persistence-id\", \"KeyType\": \"HASH\"}, {\"AttributeName\": \"sequence-nr\", \"KeyType\": \"RANGE\"}], \"Projection\": {\"ProjectionType\": \"ALL\"}, \"ProvisionedThroughput\": {\"ReadCapacityUnits\": 1, \"WriteCapacityUnits\": 1}}, {\"IndexName\": \"TagsIndex\", \"KeySchema\": [{\"AttributeName\": \"tags\", \"KeyType\": \"HASH\"}], \"Projection\": {\"ProjectionType\": \"ALL\"}, \"ProvisionedThroughput\": {\"ReadCapacityUnits\": 1, \"WriteCapacityUnits\": 1}}]" \
  --key-schema \
      AttributeName=pkey,KeyType=HASH \
      AttributeName=skey,KeyType=RANGE \
  --attribute-definitions \
      AttributeName=persistence-id,AttributeType=S \
      AttributeName=pkey,AttributeType=S \
      AttributeName=skey,AttributeType=S \
      AttributeName=sequence-nr,AttributeType=N \
      AttributeName=tags,AttributeType=S \
  --billing-mode PAY_PER_REQUEST