hashicorp / terraform-github-actions

Terraform GitHub Actions

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Terraform init: failed to get existing workspaces

alexbde opened this issue · comments

I'm running into an error Failed to get existing workspaces: http: read on closed response body running terraform init @ GitHub Actions.

This workflow configuration

  - name: Terraform init
    env:
      TF_VERSION: 0.12.13
      TF_ACTION_WORKING_DIR: ./path/to/working/dir
    uses: hashicorp/terraform-github-actions@master
    with:
      tf_actions_version: ${{ env.TF_VERSION }}
      tf_actions_subcommand: 'init'
      tf_actions_working_dir: ${{ env.TF_ACTION_WORKING_DIR }}

produces

> Run hashicorp/terraform-github-actions@master
/usr/bin/docker run ...
Downloading Terraform v0.12.13
Successfully downloaded Terraform v0.12.13
Unzipping Terraform v0.12.13
Successfully unzipped Terraform v0.12.13
init: info: initializing Terraform configuration in ./path/to/working/dir
init: error: failed to initialize Terraform configuration in ./path/to/working/dir
Initializing modules...
- # ... 7 modules init without exception ...

Initializing the backend...

Successfully configured the backend "azurerm"! Terraform will automatically
use this backend unless the backend configuration changes.

Error: Failed to get existing workspaces: http: read on closed response body

init: info: creating JSON
init: info: commenting on the pull request
##[error]Docker run failed with exit code 1

Running terraform init on my local machine at a fresh copy of same repo leads to:

$ cd ./path/to/working/dir && terraform init
Initializing modules...
- # ... same 7 modules as above ...

Initializing the backend...

Successfully configured the backend "azurerm"! Terraform will automatically
use this backend unless the backend configuration changes.

Initializing provider plugins...
- Checking for available provider plugins...
- Downloading plugin for provider "github" (hashicorp/github) 2.2.1...

The following providers do not have any version constraints # ... and so on ...

Terraform has been successfully initialized!

Do you have any idea why my pipeline is failing? 🤔

Based on this information, I do not know why your init is failing.

Try this.

  - name: Terraform init
    env:
      TF_LOG: TRACE
    uses: hashicorp/terraform-github-actions@master
    with:
      tf_actions_version: 0.12.13
      tf_actions_subcommand: 'init'
      tf_actions_working_dir: 'path/to/dir'

Also how are you authenticating to Azure? I'm assuming locally you might be using something like az login?

Okay, this is somewhere between strange and embarrassing. It was failing reproduceable when I filed this issue. Now it is working. I'm super sorry stealing your precious time :/

It's quite alright! Glad it's working!