Issue in destroying 0.12 terraform resources with Terraform 0.13

Hi,
I created a OCI resources using Terraform 0.12.
Now I imported only the terraform state file to another directory and created a provider file. Now I am trying to delete the resources using Terraform 0.13, but I am getting below error

To work with oci_database_autonomous_database.test_autonomous_database its
original provider configuration at provider[“registry.terraform.io/-/oci”] is
required, but it has been removed. This occurs when a provider configuration
is removed while objects created by that provider still exist in the state.
Re-add the provider configuration to destroy.
---------------------------------------------------------------------------.
I don’t see this issue when I try to delete the Terraform 0.11 resources with Terraform 0.12.

Thanks,
Viswanath

Quick warning: please note that we don’t recommend using the 0.13 beta with production infrastructure just yet, as the state migration will prevent you from easily moving back to 0.12.

If you’re sure you want to continue, please take a look at the Upgrading to Terraform v0.13 guide. The steps that you’ll need to take include:

  • Run terraform init to install the required modules
  • Run terraform 0.13upgrade to upgrade the required providers configuration to use the new sources

If you’ve done this already, and it still doesn’t work, could you list the exact commands you used that caused the error?

Hi,
I have tried running terraform upgrade before running terraform destroy but it didn’t work.
Let me explain the scenario.

Step 1: Create a compute instance using terraform 0.12
Step 2: Created a project ’ resource_delete ’ with provider information( attaching for you reference)
Step 3: Copied the terraform.tfstate file created in Step1 to the ’ resource_delete ’ project
Step 4: Run terraform destroy using terraform 0.13
I am getting error as shown in the screen shot attachments.

The same scenario worked fine where I could use terraform 0.12 to delete resources created with terraform 0.11.

Thanks!

Hi @vbuddi,

Thanks for reporting this!

What you’ve found here is an unsupported sequence of upgrade steps: the upgrade process relies on you running terraform apply after upgrading before you make any other changes to the configuration, because Terraform relies on information in the configuration in order to understand that what was formerly just called oci is now hashicorp/oci under Terraform 0.13. If you were to run terraform apply on the same configuration immediately after running terraform init with 0.13 then it would have the opportunity to migrate the legacy addresses stored in the state, allowing subsequent operations to work.

I can see that the current draft upgrade guide isn’t explicit about this. It just says to run the upgrade program and then run terraform init, which is sufficient to migrate the configuration but not sufficient to migrate the state. We’ll update the upgrade guide to explicitly say to run terraform apply after upgrading, before making any further changes to the configuration.

Thanks again for reporting this!