gpt4 book ai didi

amazon-dynamodb - 使用 CloudFormation 为现有 dynamoDB 表创建辅助全局索引

转载 作者:行者123 更新时间:2023-12-03 07:43:33 26 4
gpt4 key购买 nike

DynamoDB 表已创建并在生产中运行。根据当前的用例,计划添加新的二级全局索引。这可以通过AWS SDK来实现,是否可以使用CloudFormation脚本更新DynamoDB表。

任何帮助将不胜感激。

最佳答案

创建新的 CloudFormation 脚本或覆盖当前的 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

关于amazon-dynamodb - 使用 CloudFormation 为现有 dynamoDB 表创建辅助全局索引,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58652866/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com