Problem
When importing a resource into your state, an error is returned:
Error: Invalid resource instance data in state on /path/to/configuration/file.tf line 1: 16: resource "resource_type" "resource_name" { Instance resource_type.resource_name data could not be decoded from the state: unsupported attribute "unknown_attribute_name".
Cause
This issue is caused when attempting to perform an import using an version of a provider older than the one that was used to write the current state. If an attribute was added in the newer version of the provider, the older provider version will be unable to decode this unknown attribute when loading the state file while performing the import.
Solution
Check if the providers used by the configuration have version constraints specified and that the same versions are in use on the system that is performing the import as well as the system where plans and applies are usually performed.
You can check which providers were installed on the command line by running terraform version
.
If you are using Terraform 0.14+, make sure that you have the dependency lock file committed to VCS as this ensures that wherever terraform init
is performed, the same version of the providers will be used.
Outcome
If the issue persists after pinning the provider version, please reach out to HashiCorp support for additional assistance.