amazon-dynamodb - 使用 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
推荐阅读
- google-app-maker - 加载时脚本更改未激活 onValueChange
- python - 是否有 tensor.item() 等效于包含 pytorch 中列表的张量?
- r - 这些 ip 地址是否在 iana_assignments 的 ip 范围内?R语言编程
- ios - iOS 13 - 没有实例化 CBCentralManager 的蓝牙无线电的状态
- javascript - Firebase Cloud Functions onCreate对象在创建计数器时未定义
- php - WordPress 自定义元框不保存数据或显示
- koin - 作用域可以使用作用域 ID 作为参数创建对象吗?
- python - 在容器停止之前,“Docker 日志”错误地显示为空
- php - 如果 PHP 文件不存在,则创建它
- sql - 如何将 BigQuery 表转换为行序列列表,其中序列由滑动窗口及时聚合?