hashicorp/setup-terraform: Install Terraform in CI
setup-terraform installs Terraform and can wrap commands to capture their output for later steps.
Pin the Terraform version your state expects. The optional command wrapper exposes stdout, stderr, and exit code as step outputs for PR comments.
Key inputs (with:)
- terraform_version: e.g. 1.9.5 or latest.
- terraform_wrapper: true to expose outputs (default true).
- cli_config_credentials_token: Terraform Cloud/Enterprise token.
- cli_config_credentials_hostname: TFC/TFE hostname.
Example workflow
.github/workflows/ci.yml
jobs:
plan:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: hashicorp/setup-terraform@v3
with:
terraform_version: 1.9.5
- run: terraform init
- run: terraform plan -no-colorOn any runner
setup-terraform runs on any runner. Latchkey managed runners run it unchanged.
Key takeaways
- Pin terraform_version to match your state version.
- The wrapper exposes plan output for PR comment steps.
- Provide a cloud token for Terraform Cloud/Enterprise backends.
Related guides
aws-actions/configure-aws-credentials: Auth to AWS in CIReference for aws-actions/configure-aws-credentials: assume an IAM role via OIDC (no static keys) and set AWS…
google-github-actions/auth: Authenticate to Google CloudReference for google-github-actions/auth: authenticate to Google Cloud via Workload Identity Federation (keyl…
azure/login: Authenticate to Azure in CIReference for azure/login: sign in to Azure via OIDC federated credentials or a service principal so later st…