【发布时间】:2021-07-06 22:30:36
【问题描述】:
我正在使用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 给我这个错误:
有人知道如何正确部署我的表吗?不幸的是,我在使用无服务器框架时有点卡住了,尽管我认为我可以很快将其转换为 SAM 应用程序。我想先看看社区能提供什么帮助。谢谢。
【问题讨论】:
标签: amazon-dynamodb amazon-cloudformation serverless-framework