Amazon dynamodb dynamoDb中的Create table给出yml语法错误
Amazon dynamodb dynamoDb中的Create table给出yml语法错误,amazon-dynamodb,yaml,Amazon Dynamodb,Yaml,localsecondaryindex不是数组吗?我试过很多不同的版本。有无-,缩进行/道具。但我不能让它工作。 此语法将预期的params.LocalSecondaryIndexes设置为数组 CoordinatesTable: Type: 'AWS::DynamoDB::Table' Properties: KeySchema: - AttributeName: hashKey KeyType: HASH - AttributeName
localsecondaryindex
不是数组吗?我试过很多不同的版本。有无-
,缩进行/道具。但我不能让它工作。
此语法将预期的params.LocalSecondaryIndexes设置为数组
CoordinatesTable:
Type: 'AWS::DynamoDB::Table'
Properties:
KeySchema:
- AttributeName: hashKey
KeyType: HASH
- AttributeName: rangeKey
KeyType: RANGE
AttributeDefinitions:
- AttributeName: hashKey
AttributeType: "N"
- AttributeName: rangeKey
AttributeType: "S"
- AttributeName: geohash
AttributeType: "N"
LocalSecondaryIndexes:
IndexName: geohash-index
KeySchema:
- AttributeName: hashKey
KeyType: HASH
- AttributeName: geohash
KeyType: RANGE
Projection:
ProjectionType: All
ProvisionedThroughput:
ReadCapacityUnits: 10
WriteCapacityUnits: 5
TableName: CoordinatesTable
这是json格式的表,取自github项目
{
TableName: config.tableName,
ProvisionedThroughput: {
ReadCapacityUnits: 10,
WriteCapacityUnits: 5
},
KeySchema: [
{
KeyType: "HASH",
AttributeName: config.hashKeyAttributeName
},
{
KeyType: "RANGE",
AttributeName: config.rangeKeyAttributeName
}
],
AttributeDefinitions: [
{ AttributeName: config.hashKeyAttributeName, AttributeType: 'N' },
{ AttributeName: config.rangeKeyAttributeName, AttributeType: 'S' },
{ AttributeName: config.geohashAttributeName, AttributeType: 'N' }
],
LocalSecondaryIndexes: [
{
IndexName: config.geohashIndexName,
KeySchema: [
{
KeyType: 'HASH',
AttributeName: config.hashKeyAttributeName
},
{
KeyType: 'RANGE',
AttributeName: config.geohashAttributeName
}
],
Projection: {
ProjectionType: 'ALL'
}
}
]
};
}
}我认为错误消息具有误导性,应该声明
LocalSecondaryIndexes
应该是一个列表,因为这就是JSON表示中的内容。因此,在YAML中列出一个清单应该很好:
LocalSecondaryIndexes:
- IndexName: geohash-index
KeySchema:
- AttributeName: hashKey
KeyType: HASH
- AttributeName: geohash
KeyType: RANGE
Projection:
ProjectionType: All
太棒了,成功了!我只需要将ProjectionType:All改为大写ProjectionType:All为什么投反对票?我不在乎,但很高兴知道为什么。。。?