Pre-built Binaries (Recommended)
The easiest way to install Terraform is to download a pre-built binary from the HashiCorp Releases website.- macOS
- Linux
- Windows
Using Homebrew
The recommended way to install Terraform on macOS is using Homebrew:Manual Installation
- Download the appropriate package from the downloads page
- Extract the binary:
- Move it to a directory in your PATH:
Terraform releases follow semantic versioning. Check the releases page for the latest version.
Building from Source
If you prefer to build Terraform from source, or need a custom build, follow these instructions.Prerequisites
Install Go
Ensure you have Go installed. Terraform requires Go 1.25.7 or later (as specified in
.go-version).Download Go from golang.org/dl or use your package manager:Build Options
Terraform accepts certain options passed usingldflags at build time:
Disable Dev Version Reporting
By default, Terraform includes a-dev flag when reporting its version (e.g., 1.5.0-dev). To disable this:
Enable Experimental Features
Experimental features are disabled by default. To enable them:CGO Settings
For most platforms, build withCGO_ENABLED=0 for a statically linked binary:
CGO_ENABLED=1 to avoid DNS resolution issues:
Install the Built Binary
After building, move the binary to a directory in your PATH:Verify Installation
After installing Terraform, verify it’s available:System Requirements
Terraform has minimal system requirements:- Operating System: macOS, Linux, Windows, or other Unix-like systems
- Memory: At least 512MB RAM (more recommended for large infrastructures)
- Disk Space: Approximately 100MB for the binary and plugins
- Network: Internet access to download providers and modules (unless using air-gapped installations)
Terraform’s memory usage scales with the size and complexity of your infrastructure. Large deployments may require several gigabytes of RAM.
Shell Completion Setup
Terraform supports shell completion for bash, zsh, and fish. This provides tab-completion for commands and options.Install Shell Completion
- Bash
- Zsh
- Fish
Install the completion script:Then reload your shell:
Uninstall Shell Completion
To remove shell completion:The
-install-autocomplete command modifies your shell configuration file (.bashrc, .zshrc, etc.) to enable tab completion.Environment Variables
Terraform supports several environment variables for configuration:| Variable | Description |
|---|---|
TF_CLI_ARGS | Additional CLI arguments to append to all commands |
TF_DATA_DIR | Override the default .terraform directory location |
TF_IN_AUTOMATION | Set to any value to suppress prompts (for CI/CD) |
TF_LOG | Enable logging (values: TRACE, DEBUG, INFO, WARN, ERROR) |
TF_LOG_PATH | Path to write log output |
Next Steps
Now that Terraform is installed, you’re ready to start using it:Quickstart Guide
Create your first infrastructure with Terraform
Core Concepts
Learn about Terraform’s architecture and workflow
Configuration Language
Understand HashiCorp Configuration Language (HCL)
Provider Registry
Browse available providers and modules
Troubleshooting
Command Not Found
If you seecommand not found: terraform, the binary is not in your PATH:
- Verify the binary location:
which terraform - Add the directory to your PATH:
- Make the change permanent by adding it to
~/.bashrc,~/.zshrc, or equivalent
Permission Denied
If you see a permission error when running Terraform:Version Mismatch
If multiple versions of Terraform are installed, use a version manager like tfenv:Upgrading Terraform
To upgrade Terraform:- Download the new version using the same method as installation
- Replace the old binary with the new one
- Run
terraform versionto verify
- Test the new version in a development environment
- Review the changelog for breaking changes
- Update any deprecated syntax in your configurations
- Run
terraform planto verify the upgrade doesn’t cause unexpected changes