I successfully applied my basic configuration for AWS using Terraform (added a DynamoDB table):
terraform init
terraform apply -auto-approve
After I updated files by adding new resources and ran apply again, I got an error that Dynamo table already exists:
* aws_dynamodb_table.my-table: error creating DynamoDB Table: ResourceInUseException: Table already exists: my-table
How can I avoid replacing existing resources?
It turns out, that I needed to update to a newer version of Terraform . In my case, from 0.11.4 to 0.12.9
Before the change: state was updated, but not "used", so it tried to re-create ALL the resources.
After the change: apply phase skips the resources saved into state, as expected.
Hope it helps someone.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.