不是LocalSecondaryIndexes
数组吗?我尝试了很多不同的版本。有和没有-
时,缩进线/属性。但是我无法正常工作。
这种语法给了我Expected params.LocalSecondaryIndexes to be an Array
。
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'
}
}
]
};
} }
答案 0 :(得分:0)
我相信错误消息会引起误解,应该声明LocalSecondaryIndexes
应该是列表,因为这就是JSON表示形式。因此,在YAML中将其列出来应该可以正常工作:
LocalSecondaryIndexes:
- IndexName: geohash-index
KeySchema:
- AttributeName: hashKey
KeyType: HASH
- AttributeName: geohash
KeyType: RANGE
Projection:
ProjectionType: All