kitchen-terraform: kitchen converge fails in GitHub actions environment

Howdy. Running the kitchen converge command locally (using the example terraform code) works, but when I come to automate this in GitHub Actions, it fails after having created the resources in terraform with error,

$$$$$$ Parsing the Terraform output variables as JSON...
>>>>>> Parsing the Terraform output variables as JSON failed.
>>>>>> ------Exception-------
>>>>>> Class: Kitchen::ActionFailed
>>>>>> Message: 1 actions failed.
>>>>>>     Converge failed on instance <extensive-suite-aws>.  Please see .kitchen/logs/extensive-suite-aws.log for more details```

I have tried formatting the terraform output to be JSON and also removing the output completely with no success.

I have checked that the program versions between environments are the same, they are:
Terraform v0.11.14
Test Kitchen version 2.5.3
gem 2.7.6
ruby 2.5.1p57
Bundler version 2.1.4

Please advise

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 1
  • Comments: 16

Most upvoted comments

Hi @amitkumardube, @aaron-lane

I had the same issue using the hashicorp/setup-terraform action to install terraform.

Following hashicorp/setup-terraform/issues/20, you can see that hashicorp wrap terraform binary, that’s why there is a different behavior. I imagine that using your image, you install terraform using curl instead of the GH action.

You can disable the wrapper :

    - name: Setup Terraform
      uses: hashicorp/setup-terraform@v1
      with:
        terraform_wrapper: false

After that, kitchen works as expected.

Hope it will help other kitchen-terraform users 😃

@jnahelou thank you for confirming the fix!

@aaron-lane , @edwardbartholomew - I have the similar issue. This is under a public repo. Below is the URL. Do you think you can help on this please?

D ::debug::Terraform exited with code 0.

D ::debug::stdout: ***%0A

D ::set-output name=stdout:😗**%0A

D Finished running command terraform output -json in 0.3300000000000001 seconds. $$$$$$ Finished reading the output variables from the Terraform state. $$$$$$ Parsing the Terraform output variables as JSON…

Parsing the Terraform output variables as JSON failed.

https://github.com/amitkumardube/terraform-misc/runs/2426133878?check_suite_focus=true

The specs section of the Gemfile.lock includes: kitchen-terraform (5.4.0)