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

Resource recreation needed for aws_instance with root_block_device even though no attributes changed #418

Closed
hashibot opened this issue Jun 13, 2017 · 3 comments · Fixed by #12620
Labels
bug Addresses a defect in current functionality. service/ec2 Issues and PRs that pertain to the ec2 service.
Milestone

Comments

@hashibot
Copy link

This issue was originally opened by @alex-aver as hashicorp/terraform#10625. It was migrated here as part of the provider split. The original body of the issue is below.


Terraform Version

0.7.13

Affected Resource(s)

  • aws_instance

Terraform Configuration Files

resource "aws_instance" "tableau-main" {
  ami                         = "${var.tableau_ami_id}"
  availability_zone           = "${var.region}a"
  instance_type               = "${var.tableau_instance_type}"
  key_name                    = "${var.tableau_key_name}"
  monitoring                  = true
  vpc_security_group_ids      = "${var.tableau_main_sgs}"
  subnet_id                   = "${var.tableau_main_subnet}"
  iam_instance_profile        = "${var.tableau_iam_profile}"
  tenancy                     = "${var.tableau_tenancy}"

  tags {
    Name               = "tableau-${var.environment-name}"
    ProvisioningGroup  = "tableau-windows"
  }

  root_block_device {
    volume_size = "${volume-size-common}"
  }
}

I originally created an instance using the above configuration, although the volume_size attribute was hard coded.

I did some refactoring to the module and as a result I removed this instance from Terraform management, then re-imported it.

Now if I do a terraform plan, Terraform reports that the root block device will have a new resource forced, even though the only attribute that's specified is the volume_size, which is not set to be different:

    root_block_device.0.delete_on_termination:  "true" => "false" (forces new resource)
    root_block_device.~0.delete_on_termination: "" => "true" (forces new resource)
    root_block_device.~0.iops:                  "" => "<computed>" (forces new resource)
    root_block_device.~0.volume_size:           "" => "<computed>" (forces new resource)
    root_block_device.~0.volume_type:           "" => "<computed>" (forces new resource)

You can see from the terraform plan output that even though everything is the same, a new resource is forced.

If I remove the root_block_device block entirely, this problem doesn't occur, but if I want to reuse this module I'm going to need to specify volume_size

Expected Behavior

Terraform should recognize that the root block device exists and already meets my configuration specifications.

Actual Behavior

The plan forces a new resource even though nothing appears to have changed.

Steps to Reproduce

Please list the steps required to reproduce the issue, for example:

  1. have an aws_instance with a root_block_device specified, in my case with only volume_size specified
  2. terraform state rm that instance
  3. terraform import that instance back in
  4. terraform plan

References

I'd say this is kinda-sorta similar to this:

@hashibot hashibot added the bug Addresses a defect in current functionality. label Jun 13, 2017
@radeksimko radeksimko added the service/ec2 Issues and PRs that pertain to the ec2 service. label Jan 25, 2018
@mkingbe
Copy link

mkingbe commented May 9, 2018

any solution for this, as I have same issue with ebs_block_device

@ghost
Copy link

ghost commented Apr 17, 2020

This has been released in version 2.58.0 of the Terraform AWS provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template for triage. Thanks!

@ghost
Copy link

ghost commented May 17, 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 feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks!

@ghost ghost locked and limited conversation to collaborators May 17, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Addresses a defect in current functionality. service/ec2 Issues and PRs that pertain to the ec2 service.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants