I have a DynamoDB table created with this Terraform:
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"
}
}
The table was successfully populated (with 4 records, as noted in this post) but in order to solve the problem (in that post) I have added a field PK
and set that as the hash_key
field, with this:
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"
}
}
This has caused the following error, when running terraform apply
:
Error: error creating DynamoDB Table: ResourceInUseException: Table already exists: materials
What do I need to do in the .tf
to get the change accepted?