Our documentation for how to contribute was in quite a state of disrepair, with some documents still describing things as they were before moving providers into separate repositories, others making assumptions about Go development that are no longer true in modules mode, and so forth. This is an attempt at a reset to a good state that should work with the codebase as it currently stands, and should hopefully serve as a basis for iterative improvement from here. These new instructions lean primarily on standard Go toolchain usage and instruct using the Makefile only for some Terraform-specific situations that the Go toolchain does not automatically handle. The idea here is that this direct usage of primary commands in the Go toolchain is less likely to be broken by changes in future Go releases, and should be immediately familiar to anyone who has experience with Go development.
2.6 KiB
Building Terraform
This document contains details about the process for building release-style binaries for Terraform.
(If you are intending instead to make changes to Terraform and build binaries only for your local testing, see the contributing guide.)
Versioning
Until Terraform v1.0, Terraform's versioning scheme is as follows:
- Full version strings start with a zero in the initial position.
- The second position increments for major releases, which may contain backwards incompatible changes.
- The third and final position increments for minor releases, which we aim to keep backwards compatible with prior releases for the same major version.
Although the Terraform team takes care to preserve compatibility between major releases as much as possible, major release upgrades will often require specific upgrade actions for a subset of users as we refine the product design in preparation for making more specific backward-compatibility promises in a later Terraform 1.0 release.
Process
Terraform release binaries are built via cross-compilation on a Linux system, using gox.
The steps below are a subset of the steps HashiCorp uses to prepare the official distribution packages available from the download page. This process will generate an executable for each of the supported target platforms.
HashiCorp prepares release binaries on Linux amd64 systems. This build process may need to be adjusted for other host platforms.
# clone the repository if needed
git clone https://github.com/hashicorp/terraform.git
cd terraform
# Verify that the unit tests are passing
make test
# Run preparation steps and then build the executable for each target platform
# in the subdirectory "pkg".
# This generates binaries for each platform and places them in the pkg folder
make bin
Official releases are subsequently then packaged, hashed, and signed before
uploading to the HashiCorp releases service.
Those final packaging steps are not fully reproducible using the contents
of this repository due to the use of HashiCorp's private signing key. However,
you can place the generated executables in .zip
archives to produce a
similar result without the checksums and digital signature.
Release Bundles for use in Terraform Enterprise
If you wish to build distribution archives that blend official Terraform
release executables with a mixture of official and third-party provider builds,
see the terraform-bundle
tool.