Terragrunt: not working on github: invalid character 'c' looking for beginning of value

Created on 27 May 2020  路  2Comments  路  Source: gruntwork-io/terragrunt

Hi,

I am a new user to terraform and terragrunt and need some pointers on how to debug this issue. I have a (private) github project that uses terraform. I can successfully plan-all, validate-all and apply-all my infrastructure from my machine (ArchLinux, terragrunt 0.23.20, terraform v0.12.25). However it fails when I am using terragrunt from github actions.

terragrunt error: [terragrunt] Encountered the following errors: Could not parse output from terragrunt config /home/runner/work/path/to/my/terragrunt.hcl. Underlying error: invalid character 'c' looking for beginning of value

I've attached my terragrunt files. Searching for this error turn up results that suggest I might have an encoding problem, but all my terraform and terragrunt files are ASCII according to file.

terragrunt.hcl.txt
parent_terragrunt.hcl.txt

What's going on here? My github workflow file is

name: 'Terraform'

on:
  push:
    branches:
    - master
  pull_request:


env:
  GOOGLE_CREDENTIALS: ${{secrets.GKE_SA_KEY}}


jobs:
  terraform:
    name: 'Terraform'
    runs-on: ubuntu-latest

    # Use the Bash shell regardless whether the GitHub Actions runner is ubuntu-latest, macos-latest, or windows-latest
    defaults:
      run:
        shell: bash
        working-directory: terraform

    # Checkout the repository to the GitHub Actions runner
    steps:
    - name: Checkout
      uses: actions/checkout@v2

    # Install the latest version of Terraform CLI and configure the Terraform CLI configuration file with a Terraform Cloud user API token
    - name: Setup Terraform
      uses: hashicorp/setup-terraform@v1
      with:
        terraform_version: 0.12.25

    - name: Terraform Format
      run: terraform fmt -check -recursive

    - name: Setup Terragrunt
      uses: autero1/[email protected]
      with:
         terragrunt_version: 0.23.20

    - name: 'Terragrunt Init'
      run: terragrunt init

    - name: 'Terragrunt Validate'
      id: plan
      run: |
        terragrunt validate-all

question

Most helpful comment

This error occurs when terragrunt is not able to parse the result of terraform output when processing a dependency block. Specifically, the error happens when the json terragrunt pulls out with terraform output is malformed.

One thing I know about the setup-terraform github action is that it automatically installs a terraform wrapper which manipulates the stdout and stderr so that it is compatible with github action pipelines (it outputs in a way to encode results in the pipeline). I am pretty sure this is what is causing terragrunt to misread the result of output, as the stdout is not coming straight from terraform and has extra stuff.

It should work if you either turn off terraform_wrapper, or set the --terragrunt-tfpath directly to the terraform binary.

All 2 comments

This error occurs when terragrunt is not able to parse the result of terraform output when processing a dependency block. Specifically, the error happens when the json terragrunt pulls out with terraform output is malformed.

One thing I know about the setup-terraform github action is that it automatically installs a terraform wrapper which manipulates the stdout and stderr so that it is compatible with github action pipelines (it outputs in a way to encode results in the pipeline). I am pretty sure this is what is causing terragrunt to misread the result of output, as the stdout is not coming straight from terraform and has extra stuff.

It should work if you either turn off terraform_wrapper, or set the --terragrunt-tfpath directly to the terraform binary.

Thanks! Turning of the terraform_wrapper did it!

Was this page helpful?
0 / 5 - 0 ratings