Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Should I commit or ignore Terraform local module symlinks?

Terraform may create a few files in a .terraform directory.

  1. The .tfstate file, which is a json file containing the state. I can review this question for that.
  2. .tfstate backups, which I'm pretty sure I can .gitignore.
  3. The modules directory, which contains links to modules.

The terraform get command will create symlinks to my local module paths if I use local modules. Those path names are hashes, like

7a1d2376c59a613c3888163f019b98c1@ -> /Users/michael/dev/a-project/terraform/modules/netpart
dc86adf2084ae95b189765d26b75702d@ -> /Users/michael/dev/a-project/terraform/modules/cluster
e03511e017c5612ae4b9e9ebc49d4611@ -> /Users/michael/dev/a-project/terraform/modules/cluster
eb8c48ae43e85626ff456d0a58a6a6a6@ -> /Users/michael/dev/a-project/terraform/modules/netpart

All these files are in the same repo. When a coworker cloned that repo, he noticed that running terraform get resulted in new symlinks, even though the modules had not changed.

Should I add the .terraform/modules directory to .gitignore and require all developers to run terraform get any time they git pull?

like image 294
kojiro Avatar asked Oct 05 '16 13:10

kojiro


1 Answers

We gitignore the whole .terraform folder entirely.

Yes it does mean you need to run a terraform get before every action but typically when working as part of a team you will want to wrap your Terraform actions in helper scripts that can do this as well as managing remote state for you.

In fact the above documentation for terraform get explicitly advises you not to commit the folder to source control:

The modules are downloaded into a local .terraform folder. This folder should not be committed to version control.

like image 195
ydaetskcoR Avatar answered Oct 14 '22 12:10

ydaetskcoR