-
Notifications
You must be signed in to change notification settings - Fork 9.7k
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
Template file outside the module don't get saved to the state file #3732
Comments
👍 on this. Good thing i didn't run an apply. |
I ran into this issue as well... +1 |
I'm seeing a different issue in a similar context. Using Terraform v0.6.10. I also have a
Once I perform an apply, further applies do not destroy/recreate the instances, however, when I update the count variable to add more templates/instances, all of the instances get destroyed and recreated. Somewhat curious, during a
and the new resource will look something like this:
It seems odd that all of the templates, which have different content, have the same hash value. |
@erkolson Check out my update over on a related issue for details on the issue related to changing counts. The canonical thread for that issue is #3449. This "template not saved to state" thing is very weird - will add it to my shortlist to look into soon! 👌 |
Thanks @phinze |
@phinze I'm getting a potentially related bug. In my case I see Thanks! |
Hi @elblivion - are you using the Looking into the original reported issue, it does seem that it all stems from usage of the deprecated |
Hi @phinze, we switched to Config:
State:
We use modules for almost everything. We've worked around this for now through some nifty use of Docker to trick Terraform, but there ought to be a better solution. |
Ah it looks like you switched to So the full usage would look like template = "${file("${path.module}/user_data.tpl")}" This will lift the contents of the template into the state and neutralize all cross-machine path issues. Let me know if all this makes sense! I'll file a separate issue describing the BC oversight that needs to be fixed. |
@phinze oops! fixed that now, many thanks for that! Required recreating a bunch of things, but luckily we're using git for fetching modules and we had pinned the indispensable resources to a particular module version anyway. Thanks! |
Turns out the BC code allowed users to move from `filename` to `template` to squash the warning without having to switch from template paths to template contents. Here we warn when `template` is specified as a path so we can remove the functionality in the future and remove this source of confusion. refs #3732
@phinze not sure if I should create a separate issue, maybe I'll ask here first. I tried to update our current configuration to use template instead of filename, but when making a plan, terraform wants to recreate the resource because the template_file id changes (? I think). From the look at the rendered output of the template, it seems to be the same as with the Thanks in advance! |
Hey there. It has been a long time since there has been activity on this issue (our fault, sorry!), and the last known repro was against a very old version of Terraform. It is possible this issue still exists but we've addressed dozens of issues with the same type of error message in the past year. Could you please try again on the latest version and let us know if it doesn't work? The easiest way would be to simply open a new issue. Thanks! @kblcuk I'm not sure I understand your Q but if its still an issue please open a new one! |
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,
I have following module:
When I use that module, in every run, it will recreate the servers because it creates the
template-file.server-userdata
again. Somehow the template file doesn't get saved to the state file.Also see that the
user_data
is in both servers same.Workaround
Surprisingly when I copy the template file to the module folder and change:
then suddenly everything starts working!
After this fix, on first run I got:
But just run again and then it creates the machines.
The text was updated successfully, but these errors were encountered: