Terraform-provider-aws: [version 3.0.0] unsupported attribute network_interface_id on aws_instance resource

Created on 31 Jul 2020  ยท  14Comments  ยท  Source: hashicorp/terraform-provider-aws

Community Note

  • Please vote on this issue by adding a ๐Ÿ‘ reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Terraform CLI and Terraform AWS Provider Version

Affected Resource(s)

  • aws_instance

Expected Behavior

terraform apply should work as usual

Actual Behavior

```Error: Invalid resource instance data in state

on ../../../modules/instance/main.tf line 61:
61: resource "aws_instance" "instance_no_ebs" {

Instance
module.nomad_servers.module.nomad_server_instances.module.instance.aws_instance.instance_no_ebs[1]
data could not be decoded from the state: unsupported attribute
"network_interface_id".
```

Steps to Reproduce

  1. terraform init to download latest provider version (3.0.0)
  2. terraform apply

Important Factoids

  • error is not presented during plan, only apply
  • reverting to version 2.70.0 of the provider fixes the issue,
bug servicec2 servicecs upstream-terraform

Most helpful comment

Hi folks ๐Ÿ‘‹ A fix for this particular Terraform state handling issue was merged upstream in the Terraform CLI code and will release with Terraform CLI version 0.13.1 in the coming days.

If you happen to have a reproducible case of this issue with only Terraform CLI 0.12.x, please create a new bug report issue in the hashicorp/terraform repository with all the template details and the teams will triage further. Thanks.

All 14 comments

Most definitely caused by https://github.com/terraform-providers/terraform-provider-aws/pull/14001/commits/3586a1a9b5ed6f121a64f022c22b405476f44d24#diff-28aade55afa0cda57279a9d35d523488.

The error had already been bypassed on plan because the attribute is used in an output which I wrapped in a try() function, Therefore it could be planned successfully but not applied, when terraform tries to retrieve the attribute from the state.

We see a very similar problem, that actually breaks in the plan stage. This affects placement_strategy for ECS service which is now I believe ordered_placement_strategy. We probably could bypass by destroying and redeploying the infra but it would be nice to not have to.

terraform validate
Success! The configuration is valid.

terraform plan
Error: Invalid resource instance data in state

  on .terraform/modules/ecs_app/ecs_service/main.tf line 28:
  28: resource "aws_ecs_service" "service" {

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

make: *** [plan] Error 1

Hi folks ๐Ÿ‘‹ Thank you for reporting this issue and apologies for the frustrating behavior. Something is certainly amiss with the physical removal of the attributes from the provider schema, but usually Terraform core handles these just fine.

It would be very helpful if you all could provide the following information, so we can start troubleshooting this:

  • Terraform CLI version
  • Steps (e.g. commands ran, including upgrading the Terraform AWS Provider) that led to this error
  • Snippet of Terraform configuration associated with the resource reporting the error
  • A Gist with trace logging enabled so we can further troubleshoot. If you are worried about any sensitive data, it can be encrypted with the HashiCorp GPG Key or redacted as necessary.

Hopefully with those outlined, we can figure out root cause. Relevant Terraform core logic triggering the error.

  • TF CLI 0.12.29, using the hashicorp/terraform:light image in docker hub
  • terraform validate or terraform apply
  • Having an output is what led to this error for me:
output "network_interface_id" {
  description = "ID of the network interface that was created with the instance."
  value       = aws_instance.<module_name>.network_interface_id
}

In my case it's also because of an output.

I have more info in #14458 but noting here for compactness. In my case plan fails because my existing state was generated with 2.70.0 and has _removed_ attributes listed:

    {
      "module": "module.my-module",
      "mode": "data",
      "type": "aws_region",
      "name": "main",
      "provider": "provider[\"registry.terraform.io/hashicorp/aws\"].my-module",
      "instances": [
        {
          "schema_version": 0,
          "attributes": {
            "current": null,
            "description": "US East (N. Virginia)",
            "endpoint": "ec2.us-east-1.amazonaws.com",
            "id": "us-east-1",
            "name": "us-east-1"
          }
        }
      ]
    },

current was removed from the aws_region datasource in 3.0.0

Issue is happening to me as well when going from aws provider version 2.70.0 to 3.0.0

  • Version: Terraform v0.13.0-rc1, provider registry.terraform.io/hashicorp/aws v3.0.0
  • Action: terraform apply or terraform destroy
  • Resource:
resource aws_route53_zone external {
  name = var.domain-name
  comment = "${var.environment}-external-zone"

  tags = {
    Environment = var.environment
  }
}
  • Error: ...data could not be decoded from the state: unsupported attribute "vpc_id"

Edit:
Also seeing the same issue with the following:
data aws_availability_zones available {}
Error: ...data could not be decoded from the state: unsupported attribute "blacklisted_names".

And:
data aws_iam_role iam_for_lambda {
Error: ...data could not be decoded from the state: unsupported attribute "assume_role_policy_document".

Please note that I have filed a bug report upstream with Terraform core, where this error is being generated: https://github.com/hashicorp/terraform/issues/25752

Just updated to v0.13 and the terraform **plan** fails.

Terraform v0.13.0

  • provider registry.terraform.io/-/aws v3.1.0
  • provider registry.terraform.io/hashicorp/aws v3.1.0

Commands used:

terraform 0.13update (added new required_providers)
terraform init
terraform plan

Failure (multiple times for the same aws_instance resource):

Error: Invalid resource instance data in state

  on main.tf line 313:
 313: resource "aws_instance" "instance" {

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

Code snippet:

resource "aws_instance" "instance" {
  ami           = var.amis[format("%s_%s_%s_%s", var.ami_name, var.region, var.ubu_version, var.ebs_size)]
  instance_type = var.instance_type

  vpc_security_group_ids = [
    aws_security_group.ssh.id,
    aws_security_group.http.id,
    aws_security_group.openvpn.id,
  ]

  subnet_id = aws_subnet.default.id

  key_name = var.use_existingKey ? var.fixed_key_name : aws_key_pair.auth[0].id

  volume_tags = {
    Name = format("%s-ws_%s-ami_%s", var.basename, terraform.workspace, var.ami_name)
  }

  tags = {
    Name = format("%s-ws_%s-ami_%s", var.basename, terraform.workspace, var.ami_name)
  }
}

Hi folks ๐Ÿ‘‹ A fix for this particular Terraform state handling issue was merged upstream in the Terraform CLI code and will release with Terraform CLI version 0.13.1 in the coming days.

If you happen to have a reproducible case of this issue with only Terraform CLI 0.12.x, please create a new bug report issue in the hashicorp/terraform repository with all the template details and the teams will triage further. Thanks.

Is there a workaround meanwhile?

Hi folks ๐Ÿ‘‹ A fix for this particular Terraform state handling issue was merged upstream in the Terraform CLI code and will release with Terraform CLI version 0.13.1 in the coming days.

If you happen to have a reproducible case of this issue with only Terraform CLI 0.12.x, please create a new bug report issue in the hashicorp/terraform repository with all the template details and the teams will triage further. Thanks.

@andresvia alas, you have to manually edit the state file to exclude the deprecated attributes for now, I think. That worked for us at least.

More specifically, as described here: https://github.com/hashicorp/terraform/issues/25752#issuecomment-672217777

I'm going to lock this issue because it has been closed for _30 days_ โณ. This helps our maintainers find and focus on the active issues.

If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks!

Was this page helpful?
0 / 5 - 0 ratings