gpt4 book ai didi

command-line - 如何使用AWS CLI创建Dynamodb全局二级索引?

转载 作者:行者123 更新时间:2023-12-01 08:52:50 25 4
gpt4 key购买 nike

创建全局二级索引时,用于Dynamodb创建表的AWS CLI有点混乱。在CLI document中,它表示全局二级索引可以用以下表达式(简写)表示:

IndexName=string,KeySchema=[{AttributeName=string,KeyType=string},{AttributeName=string,KeyType=string}],Projection={ProjectionType=string,NonKeyAttributes=[string,string]},ProvisionedThroughput={ReadCapacityUnits=long,WriteCapacityUnits=long} ...

我的解释是,我应该做
--global-secondary-indexes IndexName=requesterIndex,Projection={ProjectionType=ALL},ProvisionedThroughput={ReadCapacityUnits=1,WriteCapacityUnits=1}

请注意,我这里不包括KeySchema来推断复杂性。控制台给我以下错误:
Parameter validation failed:
Missing required parameter in GlobalSecondaryIndexes[0]: "KeySchema"
Unknown parameter in GlobalSecondaryIndexes[0]: "WriteCapacityUnits", must be one of: IndexName, KeySchema, Projection, ProvisionedThroughput
Invalid type for parameter GlobalSecondaryIndexes[0].ProvisionedThroughput, value: ReadCapacityUnits=1, type: <class 'str'>, valid types: <class 'dict'>

因此,AWS CLI以某种方式无法识别ProvisionedThroughput的映射表达式。我尝试了几种方法来表达它,但无法使其起作用。我也未能在Google中找到任何描述该操作方法的网页。

最佳答案

这是我用来从命令行在aws文档中创建Reply示例的cli调用。可以在环境中将我最后使用的$ EP设置为EP="--endpoint-url http://localhost:8000",以在本地dynamodb而非aws上创建表。

aws dynamodb create-table --table-name Reply --attribute-definitions \
AttributeName=Id,AttributeType=S AttributeName=ReplyDateTime,AttributeType=S \
AttributeName=PostedBy,AttributeType=S AttributeName=Message,AttributeType=S \
--key-schema AttributeName=Id,KeyType=HASH \
AttributeName=ReplyDateTime,KeyType=RANGE --global-secondary-indexes \
IndexName=PostedBy-Message-Index,KeySchema=["\
{AttributeName=PostedBy,KeyType=HASH}","\
{AttributeName=Message,KeyType=RANGE}"],Projection="{ProjectionType=INCLUDE \
,NonKeyAttributes=["ReplyDateTime"]}",ProvisionedThroughput="\
{ReadCapacityUnits=10,WriteCapacityUnits=10}" --provisioned-throughput \
ReadCapacityUnits=5,WriteCapacityUnits=4 $EP

关于command-line - 如何使用AWS CLI创建Dynamodb全局二级索引?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37357397/

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