Terrafile is a binary written in Go to systematically manage external modules from Github for use in Terraform. See this article for more information on how it was introduced in a Ruby rake task.
brew tap coretech/terrafile && brew install terrafile
Download your preferred flavor from the releases page and install manually.
For example:
curl -L https://github.com/coretech/terrafile/releases/download/v{VERSION}/terrafile_{VERSION}_Linux_x86_64.tar.gz | tar xz -C /usr/local/bin
Terrafile expects a file named Terrafile
which will contain your terraform module dependencies in a yaml like format.
An example Terrafile:
tf-aws-vpc:
source: "git@github.com:terraform-aws-modules/terraform-aws-vpc"
version: "v1.46.0"
tf-aws-vpc-experimental:
source: "git@github.com:terraform-aws-modules/terraform-aws-vpc"
version: "master"
Terrafile config file in current directory and modules exported to ./vendor/modules
$ terrafile
INFO[0000] [*] Checking out v1.46.0 of git@github.com:terraform-aws-modules/terraform-aws-vpc
INFO[0000] [*] Checking out master of git@github.com:terraform-aws-modules/terraform-aws-vpc
Terrafile config file in custom directory
$ terrafile -f config/Terrafile
INFO[0000] [*] Checking out v1.46.0 of git@github.com:terraform-aws-modules/terraform-aws-vpc
INFO[0000] [*] Checking out master of git@github.com:terraform-aws-modules/terraform-aws-vpc
Terraform modules exported to custom directory
$ terrafile -p custom_directory
INFO[0000] [*] Checking out master of git@github.com:terraform-aws-modules/terraform-aws-vpc
INFO[0001] [*] Checking out v1.46.0 of git@github.com:terraform-aws-modules/terraform-aws-vpc
- Add functionality to support Terraform within a sub directory of a git repository
- Break out the main logic into seperate commands (e.g. version, help, run)
- Update tests to include unit tests for broken out commands
- Add coverage tool and badge
- May be worth renaming Terrafile config file to something that won't be misinterpreted as the binary