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

Diffs didn't match during apply: ignore_changes + referencing resources #6746

Closed
Fodoj opened this issue May 18, 2016 · 6 comments
Closed

Diffs didn't match during apply: ignore_changes + referencing resources #6746

Fodoj opened this issue May 18, 2016 · 6 comments

Comments

@Fodoj
Copy link

Fodoj commented May 18, 2016

Given: two instances, second references first one inside metadata.

Rough example, but you will get the idea:

resource "openstack_compute_instance_v2" "box-1" {
  name = "box-1"
  availability_zone = "${var.availability_zone}"
  image_id = "${var.image_id}"
  flavor_name = "m1.medium"
  key_pair = "${var.key_pair}"
  network {
    uuid = "${var.network_id}"
    fixed_ip_v4 = "192.168.0.21"
  }
  lifecycle {
    ignore_changes = ["user_data", "image_id"]
  }
}

resource "openstack_compute_instance_v2" "box-2" {
  name = "box-2-${count.index}"
  availability_zone = "${var.availability_zone}"
  image_id = "${var.image_id}"
  flavor_name = "m1.medium"
  key_pair = "${var.key_pair}"
  network {
    uuid = "${var.network_id}"
  }
  metadata {
    box_1_ip = "${openstack_compute_instance_v2.box-1.access_ip_v4}"
    random_var = "blah"
  }
  count = 2
  lifecycle {
    ignore_changes = ["user_data", "image_id"]
  }
}
  1. Create with terraform apply
  2. Change image_id
  3. Terraform plan
~ openstack_compute_instance_v2.box-2.0
    metadata.box_1_ip :            "192.168.0.21" => ""
    metadata.random_var :            "blah" => ""

Wait, what, why? Nothing was supposed to be changed, metadata is the same and metadata didnt change inside Openstack.

Okay, anyways:

  1. Terraform apply again
Error applying plan:

2 error(s) occurred:

* openstack_compute_instance_v2.box-2.0: diffs didn't match during apply. This is a bug with Terraform and should be reported as a GitHub Issue.

Please include the following information in your report:

    Terraform Version: 0.7.0
    Resource ID: openstack_compute_instance_v2.amadeus-ns-slave.0
    Mismatch reason: diff: Destroy; old: false, new: true

# Lots of lines, showing that "plan" promised to nullify metadata and then during apply it didnt happen and blah blah errors everywhere

Now we are doomed. because seems like ignore_changes doesnt work!

@jtopjian
Copy link
Contributor

@Fodoj One reason that the metadata would change is because changing the image_id causes ForceNew to trigger. Though the values of the metadata are the same, new resources are being created on both sides.

@Fodoj
Copy link
Author

Fodoj commented May 18, 2016

@jtopjian which should not happen at all (I mean, no new resources should be created), because ignore_changes ignores changes to image_id

@jtopjian
Copy link
Contributor

Yup, that's a good point. Sounds like it's more of a core issue, I think?

@Fodoj
Copy link
Author

Fodoj commented May 18, 2016

It is definitely a core issue

@mitchellh
Copy link
Contributor

This is fixed in the latest release (0.7.8).

@ghost
Copy link

ghost commented Apr 20, 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 and limited conversation to collaborators Apr 20, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants