【发布时间】:2020-07-27 17:32:13
【问题描述】:
我正在尝试创建一个 terraform 模块,借助它我可以对现有的 Dynamo DB 表进行条目。 我有这个创建发电机数据库表的代码
resource "aws_dynamodb_table" "basic-dynamodb-table" {
name = "GameScores"
billing_mode = "PROVISIONED"
read_capacity = 20
write_capacity = 20
hash_key = "UserId"
range_key = "GameTitle"
attribute {
name = "UserId"
type = "S"
}
attribute {
name = "GameTitle"
type = "S"
}
attribute {
name = "TopScore"
type = "N"
}
ttl {
attribute_name = "TimeToExist"
enabled = false
}
global_secondary_index {
name = "GameTitleIndex"
hash_key = "GameTitle"
range_key = "TopScore"
write_capacity = 10
read_capacity = 10
projection_type = "INCLUDE"
non_key_attributes = ["UserId"]
}
tags = {
Name = "dynamodb-table-1"
Environment = "production"
}
}
有什么方法可以更改现有的 dynamo db 表。
【问题讨论】:
-
欢迎来到 SO! “做出改变”到底是什么意思?您可以更改除分区和范围键之外的任何内容,而无需 terraform 破坏和重新创建表。如果您想将现有表导入 terraform,则有
terraform import(terraform.io/docs/import/usage.html) -
感谢 mate 的热烈欢迎,提出这个问题,我不想创建或重新创建任何东西,我只想在 terraform 的帮助下在 dynamo db 表中添加条目。