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

terraform init blanks files #7238

Closed
agonzalezro opened this issue Jun 20, 2016 · 3 comments · Fixed by #7273
Closed

terraform init blanks files #7238

agonzalezro opened this issue Jun 20, 2016 · 3 comments · Fixed by #7273

Comments

@agonzalezro
Copy link

agonzalezro commented Jun 20, 2016

Terraform Version

Terraform v0.7.0-dev (fe540b408f590ee2e410537672160598e300d056)

Affected Resource(s)

  • local files

Expected Behavior

From terraform init documentation:

Init will download the module from SOURCE and copy it into the DIR (which defaults to the current working directory). Version control information from the module (such as Git history) will not be copied.

The directory being initialized must be empty of all Terraform configurations. If the module has other files which conflict with what is already in the directory, they will be overwritten.

Actual Behavior

If you check the second paragraph that I mentioned earlier it shouldn't blank any file that doesn't conflict. Or at least this is what I understand from reading it.

Steps to Reproduce

$ mkdir tf

$ echo "alex was here" > tf/1

$ ls -l tf
total 8
-rw-r--r--  1 alex  wheel  14 20 Jun 15:57 1

$ terraform init tf

$ ls -l tf
total 8
-rw-r--r--  1 alex  wheel  14 20 Jun 15:57 1

$ cd tf

$ terraform init .

$ ls -l
total 0
-rw-r--r--  1 alex  wheel  0 20 Jun 15:57 1

If I run the init from outside the folder it doesn't blank the files.

@jen20
Copy link
Contributor

jen20 commented Jun 21, 2016

Hi @agonzalezro! This sounds like a nasty bug or mismatched documentation. I'll need to look into how this is implemented, but I would tend to agree that the quoted paragraph implies that files which are not in conflict should remain untouched.

@agonzalezro
Copy link
Author

I was lucky that I run it in my Desktop, but it broke recursively one folder that I had there. I wonder what would happen if I run this in my $HOME, if you need some help with it let me know and I can PR but I need some insight in advance. Thanks!

jbardin added a commit that referenced this issue Jun 22, 2016
core: Don't try to copy files over themselves
@ghost
Copy link

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

Successfully merging a pull request may close this issue.

2 participants