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
google_compute_target_pool is not idempotent when using URLs as values from google_compute_instance #9121
Comments
If this is a bug, I'd be happy to look at applying a fix if someone could clarify what the bug might be. |
Sorry for the long delay! We're trying to get through some of our backlog of issues now, and I found this one. I'm not sure if you're still having the issue, but here's why it's happening. The code is written so that an instance doesn't need to exist before it's added to the target pool. So instead of specifying the full URL, the author of the config can just specify the zone/name of the instance. After the resource is created, the state file stores that same zone/name key so that terraform doesn't think there's a diff. Unfortunately, this ends up meaning that if you specify the full URL, terraform will think there's a diff. A solution would be to do a d.Get("instances") in the read method to check if the currently set values are URLs, and if so, don't do the conversion away from them. I'm not going to work on this now, but if anyone wants to take it I'm pretty sure that would work. An easy workaround is to just convert to the zone/name syntax by doing something like: Hope that helps! |
Thanks, will try that. |
I've just been hit by this bug today, so it is still a problem in the latest terraform |
Thanks for chiming in, @queeno! Have you tried the workaround? If so, did it work? |
@danawillow Yes I have and it works 👍 Thanks for that! What I have is an instance module which creates multiple Google cloud instances and outputs
I would expect that the elements in For example, if I created an instance called
I hope terraform is consistent with populating output lists in the same order they have been created when using the Testing has shown this seems to be the case and my That said, I would rather use a |
* `google_compute_forwarding_rule.default.port_range = "80"` would save okay, but then would save to state file as "80-80", so it would always think a change was needed * `google_compute_target_pool.default.instances` items would resolve to full URLs, but saved in state as just `{zone}/{instance.name}`. * This PR uses a [workaround](hashicorp#9121 (comment)) mentioned in hashicorp#9121
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. |
Hi there,
Terraform v0.7.4
google_compute_target_pool
Plan output
Expected Behavior
This value should not be changed on every plan/apply run.
Actual Behavior
On every
plan
andapply
, this resource is modified without makes changes to the configuration.The text was updated successfully, but these errors were encountered: