Search code examples
terraform

Should I commit my .terraform-version file?


Should my .terraform-version file be added to source control/Git?

This seems like an easy and explicit way to ensure multiple developers use the same Terraform binary if provisioning infrastructure from their local machines, but I can't see any guidance suggesting as much.


Solution

  • A .terraform-version file is not something considered by Terraform itself, but some third-party "version manager" tools such as tfenv can use it to automatically select a suitable Terraform version.

    If your intention is to help ensure that everyone on your team is using the same version of Terraform then I think it would make sense to place that file under version control, and then you can handle changes to the selected Terraform version by the same change review process you use for any other changes to your Terraform configuration.

    However, since .terraform-version is a concept belonging to third-party version managers rather than Terraform itself you will need to also ensure that everyone on your team agrees to use version manager software that supports that convention. Anyone who just installs and runs a particular version of Terraform manually will not automatically benefit from that file being present.