这是我的对流层生成的JSON (DynamoDB部分):
"sandbox": {
"Properties": {
"AttributeDefinitions": [
{
"AttributeName": "audit_id",
"AttributeType": "S"
},
{
"AttributeName": "status",
"AttributeType": "S"
},
{
"AttributeName": "filename",
"AttributeType": "S"
},
{
"AttributeName": "file_detected_dt",
"AttributeType": "S"
},
{
"AttributeName": "time_taken",
"AttributeType": "N"
},
{
"AttributeName": "number_rows_processed_file",
"AttributeType": "N"
},
{
"AttributeName": "number_rows_created_db",
"AttributeType": "N"
},
{
"AttributeName": "info_messages",
"AttributeType": "S"
}
],
"KeySchema": [
{
"AttributeName": "audit_id",
"KeyType": "HASH"
}
],
"ProvisionedThroughput": {
"ReadCapacityUnits": {
"Ref": "ReadCapacityUnits"
},
"WriteCapacityUnits": {
"Ref": "WriteCapacityUnits"
}
}
},
"Type": "AWS::DynamoDB::Table"
}
CloudFormation在尝试启动VPC时给了我这个错误:Property AttributeDefinitions is inconsistent with the KeySchema of the table and the secondary indexes
.
但是…是吗?我将audit_id
指定为一个单独的键,它肯定存在于AttributeDefinitions列表中。我对CF(和Dynamo,就此事而言)非常陌生,所以我可能会错过一些非常明显的东西,但目前对我来说并不明显。
我搜索了一下,只发现一个提到这个错误,它更多地与开发人员和CF之间的层有关,而不是CF本身。
谁能指出我的模板有什么问题?
这是由于我对DynamoDB的误解。这里应该定义的只有属性将被用作键。因此,将AttributeDefinitions数组更改为以下内容就解决了问题:
"AttributeDefinitions": [
{
"AttributeName": "audit_id",
"AttributeType": "S"
}
]