hashicorp/setup-terraform@v4
Sets up Terraform CLI in your GitHub Actions workflow.
At a glance
- Latest major
v4- Repository
- hashicorp/setup-terraform
- Inputs
- 4 (0 required)
- Outputs
- 0
- Runs using
node24- License
- GPL-3.0
- Last checked
Inputs and outputs come straight from the action's official action.yml. See our editorial standards.
Usage
- uses: hashicorp/setup-terraform@v4Inputs
| Name | Required | Default | Description |
|---|---|---|---|
cli_config_credentials_hostname | No | app.terraform.io | The hostname of a HCP Terraform/Terraform Enterprise instance to place within the credentials block of the Terraform CLI configuration file. Defaults to `app.terraform.io`. |
cli_config_credentials_token | No | none | The API token for a HCP Terraform/Terraform Enterprise instance to place within the credentials block of the Terraform CLI configuration file. |
terraform_version | No | latest | The version of Terraform CLI to install. Instead of full version string you can also specify constraint string starting with "<" (for example `<1.13.0`) to install the latest version satisfying the constraint. A value of `latest` will install the latest version of Terraform CLI. Defaults to `latest`. |
terraform_wrapper | No | true | Whether or not to install a wrapper to wrap subsequent calls of the `terraform` binary and expose its STDOUT, STDERR, and exit code as outputs named `stdout`, `stderr`, and `exitcode` respectively. Defaults to `true`. |
Outputs
This action declares no outputs in its action.yml.
Examples
Install Terraform and validate
Pin the CLI version so every run uses the same Terraform.
name: Example
on:
push:
branches: [main]
permissions:
contents: read
jobs:
example:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- name: HashiCorp - Setup Terraform
uses: hashicorp/setup-terraform@v4
with:
terraform_version: 1.9.0
- run: terraform init -backend=false
- run: terraform validateEach example passed actionlint (syntax, expressions and the inputs it knows for this action). They were not run in a live repository, so replace placeholder values such as names, ARNs and paths with your own.
Something out of date or wrong? Report it on our Contact page. This page is rebuilt from the action's repository roughly once a week.