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

template_dir deletes foreign files #15365

Closed
mandelsoft opened this issue Jun 22, 2017 · 1 comment
Closed

template_dir deletes foreign files #15365

mandelsoft opened this issue Jun 22, 2017 · 1 comment

Comments

@mandelsoft
Copy link

mandelsoft commented Jun 22, 2017

Terraform Version

0.9.8

Problem

I want to process a bunch of templates into a given target directory. There are two groups of templates, wheras the processing of the second group is optional (meaning it depends on a condition used to set the count attribute). The second one might also be one or more template_file resources.

Basically template_dir looks like the ideal solution for this problem. Unfortunately it isn't if the target directory should be the same.

Actual Behavior

This resource is implemented in a way that treats the complete target directory as resulting resource.
The effect is that all additional files not described by the actual template source files are deleted, regardless whether they have been generated by a former execution of the template_dir resource or not.

As a result the content of the directory flickers, the first time terraform executes the folder is empty everything is fine, both resources generate their files into the commonly used target directory.
But for every second execution, the folder already contains files not known by the two resources,
Therefore they schedule the deletion of the files. If the second one, for example, is a template_file it sees the correct target content during the planning phase, and schedules no action.

So, every second execution this file vanishes and appears again. Similar strange things happen, if both resources are template_dirs.

Not working workarrounds

I tried to use separate target folders and copy the files to a common folder later on.
Unfortunately there is no trigger for the null_resource based on the target folder that triggers the copy step if the target folder is deleted. (for example a directory hash)

Expected Behavior

There are for sure scenarios where the actual behaviour is completely fine. But it would be a great improvement if there would be an option to tell the resource to handle only files covered by the resource and not the complete directory. This means, it should delete only files, if they were generated by a former execution of the template_dir resource.

@ghost
Copy link

ghost commented Apr 8, 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 8, 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

3 participants