简体   繁体   中英

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 ?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM