Error: Invalid resource instance data in state

I’ve been upgrading my terraform config from 0.11 to 0.13 as well as removing a module from the state file (using terraform state rm module.mymodulename).

After removing the resource above I am now running into a whole host of errors when running a plan command. Now I’m not too sure if it’s related to me removing the module or if it’s linked to the upgrade. I can see that the placement_strategy attribute has been deprecated for aws_ecs_service and I’m a bit stumped on how to safely remove it from the state file.

Placement_strategy isn’t something that I’ve defined in the resource and is just a default from the earlier version.

Anyone any advice on how to tackle the issues below? I need to get this back up and running as it’s for our development environment. I’m leaning towards removing the resource “aws_ecs_service” “myappadmin-service” and importing it again.

terraform plan

Error: Invalid resource instance data in state

  on ecs-instance-role.tf line 23:
  23: resource "aws_iam_instance_profile" "ecs-instance-profile" {

Instance aws_iam_instance_profile.ecs-instance-profile data could not be
decoded from the state: unsupported attribute "roles".

Error: Invalid resource instance data in state

  on modules\myappadmin\service.tf line 1:
   1: resource "aws_ecs_service" "myappadmin-service" {

Instance module.myappadmin.aws_ecs_service.myappadmin-service data could not be
decoded from the state: unsupported attribute "placement_strategy".

Error: Invalid resource instance data in state

  on modules\myappadmin\service.tf line 1:
   1: resource "aws_ecs_service" "myappadmin-service" {

Instance module.myappadmin.aws_ecs_service.myappadmin-service data could not be
decoded from the state: unsupported attribute "placement_strategy".

Error: Invalid resource instance data in state

  on modules\myappadmin\service.tf line 1:
   1: resource "aws_ecs_service" "myappadmin-service" {

Instance module.myappadmin.aws_ecs_service.myappadmin-service data could not be
decoded from the state: unsupported attribute "placement_strategy".

Error: Invalid resource instance data in state

  on modules\myappadmin\service.tf line 1:
   1: resource "aws_ecs_service" "myappadmin-service" {

Instance module.myappadmin.aws_ecs_service.myappadmin-service data could not be
decoded from the state: unsupported attribute "placement_strategy".

Error: Invalid resource instance data in state

  on modules\myappadmin\service.tf line 1:
   1: resource "aws_ecs_service" "myappadmin-service" {

Instance module.myappadmin.aws_ecs_service.myappadmin-service data could not be
decoded from the state: unsupported attribute "placement_strategy".

Error: Invalid resource instance data in state

  on modules\myappadmin\service.tf line 1:
   1: resource "aws_ecs_service" "myappadmin-service" {

Instance module.myappadmin.aws_ecs_service.myappadmin-service data could not be
decoded from the state: unsupported attribute "placement_strategy".
1 Like

I have similar issues upgrading from 0.12 to 0.13 and we didn’t change anything in the code. So this is almost certainly related to the upgrade.

Hi @foxj77,

AWS Provider v3.0.0 included removing some previously-deprecated arguments, and didn’t include a state upgrade rule to drop them because it was expected that Terraform would just ignore the undeclared arguments. Unfortunately this interacted poorly with the Terraform 0.13 upgrade process because it needs to also do some state migrations to switch to the new provider addressing scheme.

The good news is that Terraform v0.13.1 will include a change to make the upgrade process more tolerant of additional attributes that are not in the provider’s schema, so this should get smoother after that release, which is due out this week.

In the meantime, you might be able to work around this by upgrading to AWS provider v3.0.0 first, prior to upgrading Terraform Core. That would allow attacking the two upgrades separately, rather than having to deal with the consequences of both of them at the same time. Note that we don’t recommend going directly from Terraform v0.11 to v0.13 without upgrading to the latest v0.12 release first, because the v0.12 upgrade tools are no longer present in v0.13.