In Terraform, if a resource that was created by Terraform and exists in the state file does NOT exist inside the cloud environment, providers are supposed to treat that as a CREATE operation instead of erroring out like so:
Even deleting the resources from my .tf source code (leaving the provider block in place) did not work, and that should have been treated as a NO-OP.
Solution
Tolerate resources not being present that are listed in the state file.
Specific example: if a repository can't be found, don't blow up. Just create the repository again (or do nothing if the resource is not in the .tf source).
Rationale
Mistakes happen. Cloud resources can be deleted. After such a deletion today for me in a non-prouction environment, the provider throwing this error meant I had to do tfstate surgery to remove the resources myself, and I also had to update the DynamoDb md5 fingerprint entry to match the new hash of the state file. These would be very painful in a production environment.
Problem
In Terraform, if a resource that was created by Terraform and exists in the state file does NOT exist inside the cloud environment, providers are supposed to treat that as a CREATE operation instead of erroring out like so:
Even deleting the resources from my
.tf
source code (leaving the provider block in place) did not work, and that should have been treated as a NO-OP.Solution
Tolerate resources not being present that are listed in the state file.
Specific example: if a repository can't be found, don't blow up. Just create the repository again (or do nothing if the resource is not in the .tf source).
Rationale
Mistakes happen. Cloud resources can be deleted. After such a deletion today for me in a non-prouction environment, the provider throwing this error meant I had to do tfstate surgery to remove the resources myself, and I also had to update the DynamoDb md5 fingerprint entry to match the new hash of the state file. These would be very painful in a production environment.