How does the .terraform folder work when use modules?

954 views
Skip to first unread message

Luke Hickin

unread,
Nov 7, 2016, 1:42:29 AM11/7/16
to Terraform
I was just wondering how the terraform works when using modules and the command 'terraform get'.

Today I created a bunch of modules, and a terraform config which uses these modules. I ran terraform get and all was good. So, using git bash, I ran 'rm -rf' on the .modules folder to reset my working directory. 

This command removed the .modules folder as intended, however it also removed all terraform.tf and var.tf files containing my resource definitions and variable declarations for my modules, leaving only the terraform config which uses these modules left. I know this is not a terraform bug as deleting the .modules folder via Windows explorer doesn't delete my resource definitions.

Why would rm -rf do this? Does the .modules folder contain some sort of pointer to the original module definitions causing rm -rf to think they are nested inside of it? Was pretty frustrated considering I hadn't committed my changes as I was just testing my source paths were correct!

Thanks in advance,
Luke

Lowe Schmidt

unread,
Nov 7, 2016, 5:39:26 AM11/7/16
to terrafo...@googlegroups.com
if the modules are on the local filesystem it seems like are just
symlinks from `.terraform/modules/<long sha hash>` ->
/Path/on/local/filesystem.

That could have been what bit you ?
--
Lowe Schmidt | +46 723 867 157
> --
> This mailing list is governed under the HashiCorp Community Guidelines -
> https://www.hashicorp.com/community-guidelines.html. Behavior in violation
> of those guidelines may result in your removal from this mailing list.
>
> GitHub Issues: https://github.com/hashicorp/terraform/issues
> IRC: #terraform-tool on Freenode
> ---
> You received this message because you are subscribed to the Google Groups
> "Terraform" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to terraform-too...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/terraform-tool/486a2788-1322-4f83-98c6-d55e50d36636%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

David Adams

unread,
Nov 7, 2016, 8:21:12 AM11/7/16
to terrafo...@googlegroups.com
On Unix `rm -rf .terraform` does not behave this way, but you are using git bash on Windows? I guess you found a difference in how rm works on Windows. I'm pretty sure soft-links don't exist on NTFS in the same way as they do on Unix filesystems. But clearly Windows Explorer is deleting them differently than rm does.

--
This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.

GitHub Issues: https://github.com/hashicorp/terraform/issues
IRC: #terraform-tool on Freenode
---
You received this message because you are subscribed to the Google Groups "Terraform" group.
To unsubscribe from this group and stop receiving emails from it, send an email to terraform-tool+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/terraform-tool/CAC-wWcST9VpDH2kh8zFiQtVo%3DVPdDb0jj_zEBRLf_MN_PsXnRQ%40mail.gmail.com.
Reply all
Reply to author
Forward
0 new messages