DynamoDB 遇到不受支持的 属性 ProjectionType - 无服务器
DynamoDB Encountered unsupported property ProjectionType - Serverless
我很难理解如何使用无服务器在 DynamoDB 中创建 SecondaryGlobalIndex。这是我到目前为止得到的:
resources:
Resources:
ConnectionsTable:
Type: AWS::DynamoDB::Table
Properties:
AttributeDefinitions:
- AttributeName: connectionId
AttributeType: S
- AttributeName: sessionId
AttributeType: S
- AttributeName: clientType
AttributeType: S
BillingMode: PAY_PER_REQUEST
KeySchema:
- AttributeName: connectionId
KeyType: HASH
- AttributeName: sessionId
KeyType: HASH
- AttributeName: clientType
KeyType: HASH
GlobalSecondaryIndexes:
- IndexName: ConnectionIdIndex
KeySchema:
- AttributeName: connectionId
KeyType: HASH
Projection:
NonKeyAttributes:
- clientType
- sessionId
ProjectionType: INCLUDE
SSESpecification:
SSEEnabled: true
TimeToLiveSpecification:
AttributeName: ttl
Enabled: true
SessionHistoryTable:
Type: AWS::DynamoDB::Table
Properties:
AttributeDefinitions:
- AttributeName: sessionId
AttributeType: S
BillingMode: PAY_PER_REQUEST
KeySchema:
- AttributeName: sessionId
KeyType: HASH
SSESpecification:
SSEEnabled: true
TimeToLiveSpecification:
AttributeName: ttl
Enabled: true
SessionsTable:
Type: AWS::DynamoDB::Table
Properties:
AttributeDefinitions:
- AttributeName: sessionId
AttributeType: S
BillingMode: PAY_PER_REQUEST
KeySchema:
- AttributeName: sessionId
KeyType: HASH
SSESpecification:
SSEEnabled: true
TimeToLiveSpecification:
AttributeName: ttl
Enabled: true
但是当我尝试部署时出现此错误:
An error occurred: ConnectionsTable - Encountered unsupported property ProjectionType.
记录的投影类型 here 可以是 ALL | KEYS_ONLY | INCLUDE
我的问题是,我在 dynamoDB yaml 中做错了什么吗?
ProjectionType 和 NonKeyAttributes 是 Projection 的属性,但是 ProjectionType 与边 GlobalSecondaryIndexes
的对齐方式不正确
GlobalSecondaryIndexes:
- IndexName: ConnectionIdIndex
KeySchema:
- AttributeName: connectionId
KeyType: HASH
Projection:
NonKeyAttributes:
- clientType
- sessionId
ProjectionType: INCLUDE. <-- aligned incorrect
第二个问题是 KeySchema
应该只包含 HASH 和 RANGE 键,不能有多个 HASH 键。
总体假设connectionId是HASH,sessionId是RANGE键。
ConnectionsTable:
Type: AWS::DynamoDB::Table
Properties:
AttributeDefinitions:
- AttributeName: connectionId
AttributeType: S
- AttributeName: sessionId
AttributeType: S
BillingMode: PAY_PER_REQUEST
KeySchema:
- AttributeName: connectionId
KeyType: HASH
- AttributeName: sessionId
KeyType: RANGE
GlobalSecondaryIndexes:
- IndexName: ConnectionIdIndex
KeySchema:
- AttributeName: connectionId
KeyType: HASH
Projection:
NonKeyAttributes:
- clientType
- sessionId
ProjectionType: INCLUDE
SSESpecification:
SSEEnabled: true
TimeToLiveSpecification:
AttributeName: ttl
Enabled: true
在我的例子中,我遇到了这个错误 Encountered unsupported 属性 Attri buteType。
刚刚在 AttributeName.
中删除了 space
我很难理解如何使用无服务器在 DynamoDB 中创建 SecondaryGlobalIndex。这是我到目前为止得到的:
resources:
Resources:
ConnectionsTable:
Type: AWS::DynamoDB::Table
Properties:
AttributeDefinitions:
- AttributeName: connectionId
AttributeType: S
- AttributeName: sessionId
AttributeType: S
- AttributeName: clientType
AttributeType: S
BillingMode: PAY_PER_REQUEST
KeySchema:
- AttributeName: connectionId
KeyType: HASH
- AttributeName: sessionId
KeyType: HASH
- AttributeName: clientType
KeyType: HASH
GlobalSecondaryIndexes:
- IndexName: ConnectionIdIndex
KeySchema:
- AttributeName: connectionId
KeyType: HASH
Projection:
NonKeyAttributes:
- clientType
- sessionId
ProjectionType: INCLUDE
SSESpecification:
SSEEnabled: true
TimeToLiveSpecification:
AttributeName: ttl
Enabled: true
SessionHistoryTable:
Type: AWS::DynamoDB::Table
Properties:
AttributeDefinitions:
- AttributeName: sessionId
AttributeType: S
BillingMode: PAY_PER_REQUEST
KeySchema:
- AttributeName: sessionId
KeyType: HASH
SSESpecification:
SSEEnabled: true
TimeToLiveSpecification:
AttributeName: ttl
Enabled: true
SessionsTable:
Type: AWS::DynamoDB::Table
Properties:
AttributeDefinitions:
- AttributeName: sessionId
AttributeType: S
BillingMode: PAY_PER_REQUEST
KeySchema:
- AttributeName: sessionId
KeyType: HASH
SSESpecification:
SSEEnabled: true
TimeToLiveSpecification:
AttributeName: ttl
Enabled: true
但是当我尝试部署时出现此错误:
An error occurred: ConnectionsTable - Encountered unsupported property ProjectionType.
记录的投影类型 here 可以是 ALL | KEYS_ONLY | INCLUDE
我的问题是,我在 dynamoDB yaml 中做错了什么吗?
ProjectionType 和 NonKeyAttributes 是 Projection 的属性,但是 ProjectionType 与边 GlobalSecondaryIndexes
GlobalSecondaryIndexes:
- IndexName: ConnectionIdIndex
KeySchema:
- AttributeName: connectionId
KeyType: HASH
Projection:
NonKeyAttributes:
- clientType
- sessionId
ProjectionType: INCLUDE. <-- aligned incorrect
第二个问题是 KeySchema
应该只包含 HASH 和 RANGE 键,不能有多个 HASH 键。
总体假设connectionId是HASH,sessionId是RANGE键。
ConnectionsTable:
Type: AWS::DynamoDB::Table
Properties:
AttributeDefinitions:
- AttributeName: connectionId
AttributeType: S
- AttributeName: sessionId
AttributeType: S
BillingMode: PAY_PER_REQUEST
KeySchema:
- AttributeName: connectionId
KeyType: HASH
- AttributeName: sessionId
KeyType: RANGE
GlobalSecondaryIndexes:
- IndexName: ConnectionIdIndex
KeySchema:
- AttributeName: connectionId
KeyType: HASH
Projection:
NonKeyAttributes:
- clientType
- sessionId
ProjectionType: INCLUDE
SSESpecification:
SSEEnabled: true
TimeToLiveSpecification:
AttributeName: ttl
Enabled: true
在我的例子中,我遇到了这个错误 Encountered unsupported 属性 Attri buteType。 刚刚在 AttributeName.
中删除了 space