我有这个模板,非常简单。
DepartmentsTable:
Type: AWS::DynamoDB::Table
Properties:
TableName: "Departments"
AttributeDefinitions:
-
AttributeName: "id"
AttributeType: "S"
-
AttributeName: "client_id"
AttributeType: "S"
-
AttributeName: "department_name"
AttributeType: "S"
KeySchema:
-
AttributeName: "id"
KeyType: "HASH"
BillingMode: "PAY_PER_REQUEST"
当我使用 3 个 attributeName 进行部署时,它不会部署。
当我将模板更改为具有单个属性时,它会进行部署。
任何想法
最佳答案
DynamoDB 是无模式的,因此在这方面您必须仅在创建时定义所需的键。
由于您仅使用 id
作为哈希键,因此这必须是您定义的唯一属性,因此您可以随意添加 client_id
和 department_name
当您插入您的元素时,CFN 不需要知道这些。这就是您收到异常的原因。
DepartmentsTable:
Type: AWS::DynamoDB::Table
Properties:
TableName: "Departments"
AttributeDefinitions:
-
AttributeName: "id"
AttributeType: "S"
KeySchema:
-
AttributeName: "id"
KeyType: "HASH"
BillingMode: "PAY_PER_REQUEST"
更新:
AWSTemplateFormatVersion: "2010-09-09"
Resources:
MyTable:
Type: AWS::DynamoDB::Table
Properties:
TableName: Departments
AttributeDefinitions:
- AttributeName: id
AttributeType: S
- AttributeName: sortKey
AttributeType: S
KeySchema:
- AttributeName: id
KeyType: HASH
- AttributeName: sortKey
KeyType: RANGE
ProvisionedThroughput:
ReadCapacityUnits: 1
WriteCapacityUnits: 1
关于amazon-web-services - Cloudformation DynamoDB 部署失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/77051765/