Overview
When local commands like terraform state rm or terraform import are executed on a State file hosted in HCP Terraform, there is a situation where the mentioned error could appear:
terraform state rm databricks_library.dotenv
Removed databricks_library.dotenv
Error saving the state: unsupported attribute "application_id"
The state was not saved. No items were removed from the persisted
state. No backup was created since no modification occurred. Please
resolve the issue above and try again.
Common Cause
This error usually appears when the local version(s) of one (or many) of the used Terraform providers do not correspond to the ones that were used during the saving of the latest State file.
In this example case, this particular argument application_id
is missing/changed/or added with the newer version of the provider. This can happen with any argument with any provider, Terraform will react the same.
Note: It is important to mention that in the example above, the command tries to remove the resource databricks_library.dotenv
which is created by Databricks provider, however the error comes from another resource in the same State file that the AzureRM provider is responsible for.
How to Troubleshoot
Compare provider versions
Versions of the local Terraform providers should match exactly the versions used in the latest State file-
Enable trace logging
export TF_LOG=TRACE
In the TRACE log, all the provider versions are visible and contain more detailed information. -
Read the registry
Verify in https://registry.terraform.io/ about differences in versions and resource arguments.
That one could be tricky because in the error, it does not mention a specific resource, but you can search for the argument in the error in the State file.
How to Fix
If the Terraform provider versions match, the error will not appear, as this argument will be known.