AWS DynamoDB 创建本地二级索引时出错



我正在创建一个带有本地二级索引的dynamoDB表。如果我运行下面的语句,它工作正常。

aws dynamodb create-table                        
--table-name XYZ                             
--attribute-definitions                      
AttributeName=Id,AttributeType=N         
AttributeName=Name,AttributeType=S       
--key-schema                                 
AttributeName=Id,KeyType=HASH            
AttributeName=Name,KeyType=RANGE         
--provisioned-throughput                     
ReadCapacityUnits=5,WriteCapacityUnits=5 
--local-secondary-indexes                    
'IndexName=idx1,
KeySchema=[{AttributeName=Id,KeyType=HASH},{AttributeName=Name,KeyType=RANGE}],
Projection={ProjectionType=ALL}'

但是,如果我尝试使用以下语句添加其他属性:

aws dynamodb create-table                        
--table-name XYZ                             
--attribute-definitions                      
AttributeName=Id,AttributeType=N         
AttributeName=Name,AttributeType=S       
AttributeName=Gender,AttributeType=S     
--key-schema                                 
AttributeName=Id,KeyType=HASH            
AttributeName=Name,KeyType=RANGE         
--provisioned-throughput                     
ReadCapacityUnits=5,WriteCapacityUnits=5 
--local-secondary-indexes                    
'IndexName=idx1,
KeySchema=[{AttributeName=Id,KeyType=HASH},{AttributeName=Name,KeyType=RANGE}],
Projection={ProjectionType=ALL}'

我收到以下错误消息:

when calling the CreateTable operation: One or more parameter values 
were invalid: Some AttributeDefinitions are not used. 
AttributeDefinitions: [Id, Name, Gender], keys used: [Id, Name]

关于如何解决它的任何建议。

属性定义只能包含用于索引/键架构的属性列表。 如果不对索引或键架构使用Gender,则无需在属性定义部分中提及它。

最新更新