-
Notifications
You must be signed in to change notification settings - Fork 9.6k
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
When using data template_file or template_cloudinit_config, forces new resource, even when nothing changed #15491
Comments
Hi @cdelorme! Sorry things didn't work out as expected here. I believe the problem here is the use of The solution here is to remove the I understand that this is not very intuitive behavior right now. The way |
@apparentlymart thank you for the swift reply. When I execute without the Is there an alternative way of saying "If this file changes, then replace the Update: I just tried redundantly computing the md5 of the file instead of relying on the etag property and that appears to do the trick. Thank you for pointing me in the right direction. I am happy to close this ticket with the answer provided. |
Ahh, I think you've hit an edge case here that we know about but Terraform doesn't currently handle well: attributes that get changed as a side-effect of an update but that Terraform can't predict the value of. To be specific, without Unfortunately even if Terraform did handle this situation (which is one of the things #14887 is about), it would end up returning to your original problem, since Terraform would need to wait until apply time to determine the So with all of this said, I think computing the hash locally is the right answer here, since it means Terraform can know the result much earlier and therefore there aren't cascading dependencies on things that can only be determined during apply. Always worth keeping in mind that Terraform's goal is always to define a set of steps to be done and then perform exactly those steps, which unfortunately sometimes requires giving Terraform some additional information that would otherwise have been dynamically computed along the way, so it can get a better picture of what the necessary steps are. Thanks for following up here, and sorry this wasn't intuitive. It's a common problem that, due to some unfortunate layering, the I'm glad you found a path forward! I'm going to close this, since although there are some improvements to make here I believe they are all captured by existing issues. Thanks again! |
…ing to use hashicorp/terraform:light image. Upgraded to Kubernetes v1.7.1. In user-data template, do not use depends_on which always causes lauch configuration change; Use attribute id for a workaround. See hashicorp/terraform#15491.
Thanks for the explanation @apparentlymart . This was hard to figure out and very unintuitive. I had encountered this on |
Just spent the last hour or two on this issue of |
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. |
Terraform Version
Tested with versions
Terraform Configuration Files
This is just a summary of the related components:
The repository lives in my companies privately hosted repository, otherwise I'd gladly share.
Expected Behavior
Making no changes to any files or variables, I run
terraform plan
and expect to see something akin toPlan: 0 to add, 0 to change, 0 to destroy.
Actual Behavior
Instead, running
terraform plan
a second time shows:Sure enough, if I run
terraform apply
it will replace theaws_instance
. To reiterate, no changes have been made to any files at all.Steps to Reproduce
aws_instance
withuser_data
set via renderedtemplate_file
ortemplate_cloudinit_config
plan
orapply
a second timeIt always shows
user_data
has changed, and will replace the host, even if nothing has changed at all.References
Another issue opened on 0.6.x was closed and describes exactly the same problem I an experiencing:
There are others I looked at while troubleshooting, but I didn't want to find them again.
Workaround
Currently the solution is to use EOF "here doc" syntax, which directly interpolates the values.
This makes it a bit harder to edit content, and I have not figured out how to combine
base64encode
with EOF syntax.The text was updated successfully, but these errors were encountered: