Skip to content

Commit

Permalink
add documentation on Terraform's available build options
Browse files Browse the repository at this point in the history
  • Loading branch information
radditude committed Apr 10, 2023
1 parent c323954 commit a79795e
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions BUILDING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Building from Source

Pre-built binaries are available for download for a variety of supported platforms through the [HashiCorp Releases website](https://releases.hashicorp.com/terraform/).

However, if you'd like to build Terraform yourself, you can do so using the Go build toolchain with required options.

## Prerequisites

1. Ensure you've installed the Go language version specified in [`.go-version`](https://github.com/hashicorp/terraform/blob/main/.go-version).
2. Clone this repository to a location of your choice.

## Terraform Build Options

Terraform accepts certain options passed using `ldflags` at build time which control the behavior of the resulting binary.

### `github.com/hashicorp/terraform/version.useDevelopmentVersion`

Terraform will include a `-dev` flag when reporting its own version (ex: 1.5.0-dev) unless this option is set to `no`:

```
go build -ldflags "-w -s -X 'github.com/hashicorp/terraform/version.useDevelopmentVersion=no'" -o bin/ .
```

### `main.experimentsAllowed`

Experimental features of Terraform will be disabled unless this option is set to `yes`:

```
go build -ldflags "-w -s -X 'main.experimentsAllowed=yes'" -o bin/ .
```

## Go Options

The Terraform release process uses the Go toolchain defaults for the given operating system and processor architecture.


0 comments on commit a79795e

Please sign in to comment.