【问题标题】:DynamoDB: create table with global index from cli - parameter validation failedDynamoDB:从 cli 创建具有全局索引的表 - 参数验证失败
【发布时间】:2023-02-07 18:38:43
【问题描述】:

我正在尝试使用这样的全局索引创建 DynamoDB 表:

aws create-table \
--table-name test1 --attribute-definitions AttributeName=id,AttributeType=S AttributeName=consumerId,AttributeType=S \
--key-schema AttributeName=id,KeyType=HASH \
--global-secondary-indexes IndexName=consumerIdInd,KeySchema=[{AttributeName=consumerId,KeyType=HASH}],Projection={ProjectionType=ALL}

这将返回:

参数验证失败: 参数 GlobalSecondaryIndexes[0].KeySchema[0] 的类型无效,值:AttributeName=consumerId,类型:<class 'str'>,有效类型:<class 'dict'> 参数 GlobalSecondaryIndexes[1].KeySchema[0] 的类型无效,值:KeyType=HASH,类型:<class 'str'>,有效类型:<class 'dict'>

如何解决这个问题?

【问题讨论】:

    标签: amazon-web-services amazon-dynamodb


    【解决方案1】:

    您的命令没有服务名称 dynamodb 那么您需要将 --global-secondary-indexes 括在双引号之间。

    aws dynamodb create-table --table-name test1 --attribute-definitions AttributeName=id,AttributeType=S AttributeName=consumerId,AttributeType=S --key-schema AttributeName=id,KeyType=HASH --global-secondary-indexes "IndexName=consumerIdInd,KeySchema=[{AttributeName=consumerId,KeyType=HASH}],Projection={ProjectionType=ALL}" --billing-mode PAY_PER_REQUEST
    

    测试它有效

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-11-12
      • 2020-02-27
      • 2016-10-28
      • 2014-03-11
      • 2015-11-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多