我有一个用这个 Terraform 创建的 DynamoDB 表:
resource "aws_dynamodb_table" "materials_table" {
name = "materials"
hash_key = "MATERIAL"
billing_mode = "PROVISIONED"
read_capacity = 5
write_capacity = 5
attribute {
name = "MATERIAL"
type = "S"
}
}
该表已成功填充(有 4 条记录,如本文所述),但为了解决问题(在那篇文章中),我添加了一个字段PK
并将其设置为hash_key
字段,如下所示:
resource "aws_dynamodb_table" "materials_table" {
name = "materials"
hash_key = "PK"
billing_mode = "PROVISIONED"
read_capacity = 5
write_capacity = 5
attribute {
name = "PK"
type = "S"
}
}
这在运行时导致了以下错误terraform apply
:
Error: error creating DynamoDB Table: ResourceInUseException: Table already exists: materials
我需要做什么.tf
才能让更改被接受?