【发布时间】:2021-04-11 17:09:44
【问题描述】:
我正在使用AWS SAM 部署一个 DynamoDB 表,我的 template.yaml 看起来像这样:
AWSTemplateFormatVersion: "2010-09-09"
Transform: AWS::Serverless-2016-10-31
DynamoDBTable:
Type: AWS::DynamoDB::Table
Properties:
BillingMode: PAY_PER_REQUEST
AttributeDefinitions:
- AttributeName: owner
AttributeType: S
KeySchema:
- AttributeName: owner
KeyType: HASH
我使用sam build && sam deploy 来(重新)部署它。
当我添加 sortKey 和/或 GlobalSecondaryIndex 时,yaml 文件看起来像这样:
AWSTemplateFormatVersion: "2010-09-09"
Transform: AWS::Serverless-2016-10-31
DynamoDBTable:
Type: AWS::DynamoDB::Table
Properties:
BillingMode: PAY_PER_REQUEST
AttributeDefinitions:
- AttributeName: owner
AttributeType: S
- AttributeName: Timestamp
AttributeType: S
KeySchema:
- AttributeName: owner
KeyType: HASH
- AttributeName: Timestamp
KeyType: RANGE
GlobalSecondaryIndexes:
- IndexName: TestIndex
KeySchema:
- AttributeName: owner
KeyType: HASH
- AttributeName: Timestamp
KeyType: RANGE
Projection:
ProjectionType: KEYS_ONLY
根据docs 更新这些字段应该是可能的(没有中断)。 但在我的情况下,部署命令总是重新创建整个表(删除所有数据)。 我在这里做错了吗?
编辑
也许我的解释不清楚。我尝试同时添加(GSI 和 sortKey),但我也尝试逐一添加,即只需添加 GSI。
【问题讨论】: