Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[v0.12.6] provider.aws v3.1.0 still shows "Invalid resource instance data in state" #25827

Closed
hacos opened this issue Aug 12, 2020 · 7 comments
Closed
Labels
bug duplicate issue closed because another issue already tracks this problem v0.12 Issues (primarily bugs) reported against v0.12 releases

Comments

@hacos
Copy link

hacos commented Aug 12, 2020

Terraform Version

Terraform v0.12.6
+ provider.aws v3.1.0
+ provider.template v2.1.2

Note: seems like it might still be happening with Terraform v0.13.0? hashicorp/terraform-provider-aws#14431 (comment)

Terraform Configuration Files

Note: redacted for privacy purposes

resource "aws_instance" "standard_instance" {
  count                  = var.instance_count
  ami                    = var.instance_ami
  instance_type          = var.instance_type
  vpc_security_group_ids = var.vpc_security_group_ids
  subnet_id              = var.subnet_ids[count.index % length(var.subnet_ids)]
  key_name               = var.key_name
  iam_instance_profile   = var.iam_instance_profile
  ebs_optimized          = var.ebs_optimized

  user_data = var.instance_user_data

  root_block_device {
    volume_type = var.root_volume_type
    volume_size = var.root_volume_size
    encrypted   = var.encrypted
  }

  dynamic "ebs_block_device" {
    for_each = var.ebs_devices
    content {
      device_name = ebs_block_device.value.device_name
      volume_type = ebs_block_device.value.volume_type
      volume_size = ebs_block_device.value.volume_size
      iops        = lookup(ebs_block_device.value, "iops", null)
      encrypted   = var.encrypted
    }
  }

  dynamic "ephemeral_block_device" {
    for_each = var.ephemeral_devices
    content {
      device_name  = ephemeral_block_device.value.device_name
      virtual_name = ephemeral_block_device.value.virtual_name
    }
  }

  lifecycle {
    ignore_changes = [
      user_data,
      ami,
      ebs_block_device,
      ephemeral_block_device,
      subnet_id
    ]
  }
}

Debug Output

Need to review and scrub before posting

Crash Output

Expected Behavior

The plan to work. It should have replaced the instance because of a new variable. Interestingly enough, if I run just terraform plan instead of using -target= the plan outputs properly. Since these aws_instances are being replaced, I'd rather not take down the entire group of them all at once, hence the -target= flag.

Actual Behavior

Got an error similar to hashicorp/terraform-provider-aws#14431

Error: Invalid resource instance data in state

  on ../../../../base_modules/standard_instance/standard_instance.tf line 11:
  11: resource "aws_instance" "standard_instance" {

Instance module.REDACTED.aws_instance.standard_instance[3] data
could not be decoded from the state: unsupported attribute
"network_interface_id".

Steps to Reproduce

terraform init
terraform plan -target=module.REDACTED.aws_instance.standard_instance[3]

Additional Context

References

Was told by this comment to log an issue if it's still happening with Terraform v0.12.X (which I am on). hashicorp/terraform-provider-aws#14431 (comment)

@hacos hacos added bug new new issue not yet triaged labels Aug 12, 2020
@danieldreier
Copy link
Contributor

Hi! Thanks for reporting this. Based on the error report you showed, I think this is probably a valid issue, and I'd like to reproduce it locally.

To do that, I have to be able to run this and run it on my workstation without inventing any details in order to be confident we're seeing the same behavior. As-is, I don't have your vars, so I'd have to invent some details. Can you please restate your reproduction case such that I can copy-paste it and run it locally? If it's easier to provide via a github repo rather than a copy-paste, you're welcome to make a PR against https://github.com/danieldreier/terraform-issue-reproductions to share it, or provide your own GH repo.

@danieldreier danieldreier added waiting for reproduction unable to reproduce issue without further information v0.12 Issues (primarily bugs) reported against v0.12 releases and removed new new issue not yet triaged labels Aug 12, 2020
@hacos
Copy link
Author

hacos commented Aug 12, 2020

Hi! I can try but I believe the issue isn't with the variables but with the state itself. In any case, here's the variables.tf and terraform.tfvars file:

variable "instance_ami" {}
variable "instance_type" {}
variable "name" {}
variable "vpc_security_group_ids" {
  type = list(string)
}
variable "subnet_ids" {
  type = list(string)
}
variable "instance_user_data" {
  default = ""
}
variable "key_name" {
}
variable "iam_instance_profile" {
  default = ""
}
variable "instance_count" {
  default = 1
}
variable "cluster_tag" {
}
variable "deployment_tag" {
}
variable "ebs_optimized" {
  default = false
}
variable "owner_tag" {
  default = "InfraShared"
}
variable "ebs_devices" {
  type    = list(map(string))
  default = []
}
variable "ephemeral_devices" {
  type    = list(map(string))
  default = []
}
variable "encrypted" {
  default = true
}
variable "root_volume_type" {
  default = "gp2"
}
variable "root_volume_size" {
  default = 64
}
variable "extra_tags" {
  type    = map(string)
  default = {}
}
instance_ami   = "REDACTED"
instance_type  = "t3.medium"
name           = "terraform-bug-25827"
key_name       = "REDACTED"
cluster_tag    = "terraform-bug"
deployment_tag = "terraform"

@Craigfis
Copy link

Craigfis commented Aug 13, 2020

I'm also hitting this error (with Terraform 0.13.0). In my case it is complaining because my state file contains the obsolete API gateway attribute "request_parameters_in_json".

@mshkrebtan
Copy link

Editing the state file and removing the unsupported attributes helped me.

  • Pull the state from the remote location:

    terraform state pull > tf-state.json
  • Edit the state file: remove the unsupported attributes and increment the serial number.

  • Push the state to the remote location:

    terraform state push tf-state.json
  • Run terraform plan again.

@Mikescops
Copy link

Scary but it works 😨

@mildwonkey
Copy link
Contributor

👋 Hi! This is a duplicate of #25752 - this issue will be fixed in the next terraform release. Thanks!

@mildwonkey mildwonkey added duplicate issue closed because another issue already tracks this problem and removed waiting for reproduction unable to reproduce issue without further information labels Aug 20, 2020
@ghost
Copy link

ghost commented Oct 11, 2020

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 have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@ghost ghost locked as resolved and limited conversation to collaborators Oct 11, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug duplicate issue closed because another issue already tracks this problem v0.12 Issues (primarily bugs) reported against v0.12 releases
Projects
None yet
Development

No branches or pull requests

6 participants