Skip to content

A binary written in Go to systematically manage external modules from Github for use in Terraform

License

Notifications You must be signed in to change notification settings

segmentio/terrafile

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Terrafile

Terrafile is a binary written in Go to systematically manage external modules from Github for use in Terraform. This is a fork of the original version found here: https://github.com/coretech/terrafile

How to install

macOS

brew tap segmentio/packages
brew install segmentio/packages/terrafile

Linux

Download your preferred flavor from the releases page and install manually.

How to use

Terrafile expects a file named Terrafile which will contain your terraform module dependencies in a yaml like format.

Terrafile config file in custom directory

$ terrafile -f config/Terrafile

Terraform modules exported to custom directory

$ terrafile -p /path/to/custom_directory

Segment Terrafile Format

Segment Terrafile is an internal format that specifies sources with a list of its versions. Each version is vendored under .terrafile/<user>/<repo>/<ref>

⚠️ the major downside of using this format is that vendored modules has version in their path. So once you want to upgrade module version, you will need to modify both Terrafile and all module usages. Check out Community Terrafile Format which doesn't have such downside

An example Terrafile:

git@github.com:segmentio/terracode-modules:
  - chamber_v2.0.0
  - iam_v1.0.0
  - master
$ terrafile
[*] Cloning   git@github.com:segmentio/terracode-modules
[*] Vendoring ref chamber_v2.0.0
[*] Vendoring ref iam_v1.0.0
[*] Vendoring ref master
$ ls -A1 .terrafile/segmentio/terracode-modules
chamber_v2.0.0
iam_v1.0.0
master

Community Terrafile Format

Community Terrafile is a community supported format implemented in various languages (e.g. github: coretech/terrafile, npm: terrafile). Each version is vendored under .terrafile/<alias>

In comparison with Segment Terrafile Format, module versions are not included in the vendored path. So once you want to upgrade module version, only Terrafile needs to be updated and all module usages will be left untouched.

An example Terrafile:

terracode-modules-chamber:
  source: "git@github.com:segmentio/terracode-modules"
  version: "chamber_v2.0.0"
terracode-modules-iam:
  source: "git@github.com:segmentio/terracode-modules"
  version: "iam_v1.0.0"
terracode-modules:
  source: "git@github.com:segmentio/terracode-modules"
  version: "master"
$ terrafile
[*] Cloning   git@github.com:segmentio/terracode-modules
[*] Vendoring ref chamber_v2.0.0
[*] Vendoring ref iam_v1.0.0
[*] Vendoring ref master
$ ls -A1 .terrafile
terracode-modules-chamber
terracode-modules-iam
terracode-modules

About

A binary written in Go to systematically manage external modules from Github for use in Terraform

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Go 92.4%
  • Shell 7.1%
  • Makefile 0.5%