You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Note: this example is using postgres database resources, but the problem is not specific to this provider/resource, but a general problem with imports in the destroy phase.
With this configuration in a state where a previous destroy has partially completed, and has destroyed test_1, but has failed to destroy test_2 for any reason (eg network error, permissions error, or using -target), subsequent terraform destroy operations will fail when attempting to import the test_1 database that no longer exists.
terraform destroy should have ignored the test_1 database and successfully deleted the test_2 database.
Actual Behavior
Terraform errored in the plan stage with the following:
$ TF_LOG_PATH=./debug.log TF_LOG=trace terraform destroy
postgresql_database.one: Preparing import... [id=test_1]
postgresql_database.one: Refreshing state... [id=test_1]
postgresql_database.two: Refreshing state... [id=test_2]
╷
│ Error: Cannot import non-existent remote object
│
│ While attempting to import an existing object to "postgresql_database.one", the provider detected that no
│ object exists with the given id. Only pre-existing objects can be imported; check that the id is correct
│ and that it is associated with the provider's configured region or endpoint, or use "terraform apply" to
│ create a new remote object for this resource.
╵
Steps to Reproduce
With a postgres database with a test_1 and test_2 database existing in it.
Populate postgres provider details
terraform init
terraform apply
terraform destroy -target postgresql_database.one (Simulate a destroy that's partially completed due to an error using -target)
terraform destroy - This one will error
Additional Context
Details about the use-case:
We have an environment with an RDS instance that's restored from a snapshot (taken from a different environment). On creation we want terraform to import the database/user/schema resources so that it can ensure they're setup for this environment (passwords set correctly etc...). We're running into this issue when destroying the environment, if anything errors in the destroy, it's then in a state where we can't retry the destroy.
References
No response
The text was updated successfully, but these errors were encountered:
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.
Terraform Version
Terraform Configuration Files
Note: this example is using postgres database resources, but the problem is not specific to this provider/resource, but a general problem with imports in the destroy phase.
With this configuration in a state where a previous destroy has partially completed, and has destroyed test_1, but has failed to destroy test_2 for any reason (eg network error, permissions error, or using
-target
), subsequentterraform destroy
operations will fail when attempting to import the test_1 database that no longer exists.Debug Output
https://gist.github.com/alext/e8dfff7527317b672194691dad52ec55
Expected Behavior
terraform destroy
should have ignored the test_1 database and successfully deleted the test_2 database.Actual Behavior
Terraform errored in the plan stage with the following:
Steps to Reproduce
With a postgres database with a test_1 and test_2 database existing in it.
terraform init
terraform apply
terraform destroy -target postgresql_database.one
(Simulate a destroy that's partially completed due to an error using -target)terraform destroy
- This one will errorAdditional Context
Details about the use-case:
We have an environment with an RDS instance that's restored from a snapshot (taken from a different environment). On creation we want terraform to import the database/user/schema resources so that it can ensure they're setup for this environment (passwords set correctly etc...). We're running into this issue when destroying the environment, if anything errors in the destroy, it's then in a state where we can't retry the destroy.
References
No response
The text was updated successfully, but these errors were encountered: