Skip to content
Latchkey

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-color

On 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

Run this faster and cheaper on Latchkey managed runners. Start free →