DynamoDB 表已创建并在生产中运行。根据当前用例,计划添加新的二级全局索引。这可以通过 AWS SDK 实现,是否可以使用 CloudFormation 脚本更新 DynamoDB 表。
任何帮助将不胜感激。
DynamoDB 表已创建并在生产中运行。根据当前用例,计划添加新的二级全局索引。这可以通过 AWS SDK 实现,是否可以使用 CloudFormation 脚本更新 DynamoDB 表。
任何帮助将不胜感激。
创建一个新的或覆盖您当前的 CloudFormation 脚本
Resources
DDBTable:
Type: AWS::DynamoDB::Table
Properties:
TableName: YOUR_EXISTING_TABLE_NAME
AttributeDefinitions: #List out all existing cols here
-
AttributeName: "ColX" # hash key
AttributeType: "S"
-
AttributeName: "ColY" # range key
AttributeType: "S"
-
AttributeName: "ColZ" # used for your Global Secondary Index
AttributeType: "S"
KeySchema: # List out your main Hash & Range Key
-
AttributeName: "ColX"
KeyType: "HASH"
-
AttributeName: "ColY"
KeyType: "RANGE"
GlobalSecondaryIndexes: # new Global Secondary Index
- IndexName: INDEX_NAME
KeySchema:
- AttributeName: ColZ #different than your main table Hash Key
KeyType: HASH
Projection:
ProjectionType: ALL