Global Secondary Index `ProvisionedThroughput` 的无服务器 DynamoDB 资源定义错误 属性
Serverless DynamoDB Resource definition error for Global Secondary Index `ProvisionedThroughput` property
我正在使用 serverless framework,但在我的 serverless.yml
中遇到了一个非常奇怪的 GSI 定义问题。当我使用我原来的定义时:
resources:
Resources:
GPSTable:
Type: AWS::DynamoDB::Table
Properties:
AttributeDefinitions:
- AttributeName: joined
AttributeType: S
- AttributeName: serial
AttributeType: S
- AttributeName: timestamp
AttributeType: S
KeySchema:
- AttributeName: serial
KeyType: HASH
- AttributeName: timestamp
KeyType: RANGE
GlobalSecondaryIndexes:
- IndexName: ValidGPSIndex
KeySchema:
- AttributeName: joined
KeyType: HASH
- AttributeName: timestamp
KeyType: RANGE
Projection:
NonKeyAttributes:
- Altitude
- Altitude_Unit
- Checksum
- Fix_Quality
- GPS_Time
- HDOP
- Height_of_GEOID
- Height_of_GEOID_Unit
- Latitude
- Latitude_Direction
- Longitude
- Longitude_Direction
- No_of_Tracked_Satellites
- Time_Since_Last_DGPS_Update
ProjectionType: INCLUDE
ProvisionedThroughput:
ReadCapacityUnits: 5
WriteCapacityUnits: 5
sls deploy
命令给我以下错误:
所以我更改了 serverless.yml
并在 GSI 上添加了适当的 ProvisionedThroughput 属性,如下所示:
...
GlobalSecondaryIndexes:
- IndexName: ValidGPSIndex
KeySchema:
- AttributeName: joined
KeyType: HASH
- AttributeName: timestamp
KeyType: RANGE
Projection:
NonKeyAttributes:
- Altitude
- Altitude_Unit
- Checksum
- Fix_Quality
- GPS_Time
- HDOP
- Height_of_GEOID
- Height_of_GEOID_Unit
- Latitude
- Latitude_Direction
- Longitude
- Longitude_Direction
- No_of_Tracked_Satellites
- Time_Since_Last_DGPS_Update
ProjectionType: INCLUDE
ProvisionedThroughput:
ReadCapacityUnits: 5
WriteCapacityUnits: 5
...
现在,运行 sls deploy
给我这个错误:
有人知道如何正确部署我的 table 吗?不幸的是,我有点坚持使用无服务器框架,尽管我认为在非常短的时间内我可以将其转换为 SAM 应用程序。我想先看看社区能提供什么帮助。谢谢。
您只是遇到了缩进问题。 ProvisionedThroughput
属性 是索引的一部分,而不是 Projection
。
我正在使用 serverless framework,但在我的 serverless.yml
中遇到了一个非常奇怪的 GSI 定义问题。当我使用我原来的定义时:
resources:
Resources:
GPSTable:
Type: AWS::DynamoDB::Table
Properties:
AttributeDefinitions:
- AttributeName: joined
AttributeType: S
- AttributeName: serial
AttributeType: S
- AttributeName: timestamp
AttributeType: S
KeySchema:
- AttributeName: serial
KeyType: HASH
- AttributeName: timestamp
KeyType: RANGE
GlobalSecondaryIndexes:
- IndexName: ValidGPSIndex
KeySchema:
- AttributeName: joined
KeyType: HASH
- AttributeName: timestamp
KeyType: RANGE
Projection:
NonKeyAttributes:
- Altitude
- Altitude_Unit
- Checksum
- Fix_Quality
- GPS_Time
- HDOP
- Height_of_GEOID
- Height_of_GEOID_Unit
- Latitude
- Latitude_Direction
- Longitude
- Longitude_Direction
- No_of_Tracked_Satellites
- Time_Since_Last_DGPS_Update
ProjectionType: INCLUDE
ProvisionedThroughput:
ReadCapacityUnits: 5
WriteCapacityUnits: 5
sls deploy
命令给我以下错误:
所以我更改了 serverless.yml
并在 GSI 上添加了适当的 ProvisionedThroughput 属性,如下所示:
...
GlobalSecondaryIndexes:
- IndexName: ValidGPSIndex
KeySchema:
- AttributeName: joined
KeyType: HASH
- AttributeName: timestamp
KeyType: RANGE
Projection:
NonKeyAttributes:
- Altitude
- Altitude_Unit
- Checksum
- Fix_Quality
- GPS_Time
- HDOP
- Height_of_GEOID
- Height_of_GEOID_Unit
- Latitude
- Latitude_Direction
- Longitude
- Longitude_Direction
- No_of_Tracked_Satellites
- Time_Since_Last_DGPS_Update
ProjectionType: INCLUDE
ProvisionedThroughput:
ReadCapacityUnits: 5
WriteCapacityUnits: 5
...
现在,运行 sls deploy
给我这个错误:
有人知道如何正确部署我的 table 吗?不幸的是,我有点坚持使用无服务器框架,尽管我认为在非常短的时间内我可以将其转换为 SAM 应用程序。我想先看看社区能提供什么帮助。谢谢。
您只是遇到了缩进问题。 ProvisionedThroughput
属性 是索引的一部分,而不是 Projection
。