Attribute Errors in State File After Upgrading from Terraform 12 to 13

Hi,

I recently upgraded from Terraform 0.12.31 to 0.13.7. Version 2.70.0 of the AWS Provider plug-in works fine across both versions. However, if I try to use 0.13.7 with version 3.0 of the AWS Provider plug-in, I see errors like the following when I run terraform console:

> Error: Invalid resource instance data in state
> 
>   on ../common/instances/single/instance.tf line 5:
>    5: resource "aws_instance" "instance" {
> 
> Instance
 module.bastion.aws_instance.instance data could not be decoded from
the state: unsupported attribute "network_interface_id".


Error: Invalid resource instance data in state

  on ../common/instances/single/instance.tf line 5:
   5: resource "aws_instance" "instance" {

Instance module.bastion.aws_instance.instance data could not be decoded from
the state: unsupported attribute "network_interface_id".

terraform plan does not expose these errors, but I’m afraid now to run terraform apply, lest something unexpected happen to my state file.

Does anyone know what I should do to resolve these inconsistencies? It seems like editing the state file manually to remove the deprecated attributes goes against best practices.

Thanks.

Major version jumps for providers indicates that there are backwards incompatible changes, so you may have to make adjustments to your code. Take a look at the v3 upgrade guide from https://registry.terraform.io/providers/hashicorp/aws/latest/docs/guides/version-3-upgrade

Thank you, Stuart. I did take a look at that, but there is no mention of this particular attribute anywhere in the document, let alone in the section for aws_instance.

I’m wondering if I should pause upgrading to Terraform 14 and 1.0 until I can discover the code changes needed to resolve this error. I don’t want to bury myself further, lest I should have to roll back to Terraform 12, which–I’m merely speculating–might handle upgrading the state file format to resolve this 3.0 issue better than Terraform 13.

Hi @jpagano-timemag,

The content of the plan is what you should trust here, since that is a record of the actions that will be taken during apply. There are no changes to be made the configuration, as network_interface_id is not an attribute that could be set in the configuration since was only computed.

This was likely a bug where the console command could not decode the state because it needed to be upgraded by the provider, but that is not done when using the console command.

Thank you, @jbardin. That’s really helpful.

However, it’s not clear to me from your comment how I might resolve the issue. Do I have to tolerate error messages in terraform console about deprecated attributes indefinitely? How do I know that the errors won’t eventually show up in plan or apply? How can I update the schema in the state file to make the problem go away?

Thanks again!

There should be no errors once you apply the plan to update the state. The plan does not show any errors, because the errors should not exist once the state has been updated. Any schema upgrades that happened will be stored in the new state, and at that point the console command should work.

Thank you. I’ll try and see what happens.