Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fork/exec $GITHUB_WORKSPACE/.github/scripts/tfwrapper.sh: no such file or directory #79

Open
LittleWat opened this issue Sep 26, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@LittleWat
Copy link

LittleWat commented Sep 26, 2024

Describe the bug
Unfortunately, terragrunt does not catch the tofu error. This is quite annoying when debugging the terraform codes.

Based on https://community.gruntwork.io/t/how-to-process-terraform-apply-logs-for-catching-errors-in-ci/656/4 ,

I prepared the wrapper shell

  • .github/scripts/tfwrapper.sh
#!/bin/bash

tofu "$@" 2>&1 | tee ./terraform.log

and set the github workflow as follows:

- name: Apply
  uses: gruntwork-io/terragrunt-action@cf355638dbd066b6a70eb01f31ad9293870a0e34 # v2.1.4
  with:
    tofu_version: ${{ env.TOFU_VERSION }}
    tg_version: ${{ env.TG_VERSION }}
    tg_dir: ${{ env.WORK_DIR }}
    # to catch the error of "tofu apply" based on https://github.com/gruntwork-io/terragrunt/issues/74#issuecomment-471082576
    tg_command: 'run-all apply --terragrunt-tfpath $GITHUB_WORKSPACE/.github/scripts/tfwrapper.sh'

However, it fails with fork/exec $GITHUB_WORKSPACE/.github/scripts/tfwrapper.sh: no such file or directory

I tried the following INPUT_PRE_EXEC_1 and it could cat as expected.

     - name: Apply
        env:
          INPUT_PRE_EXEC_1: |
            cat $GITHUB_WORKSPACE/.github/scripts/tfwrapper.sh

so I'm wondering how to fix this error.

Expected behavior

It should find $GITHUB_WORKSPACE/.github/scripts/tfwrapper.sh

Versions

  • Terragrunt Action version: # v2.1.4
  • Environment details (Terragrunt version, Terraform version, etc.):
    • TOFU_VERSION: 1.8.1
    • TG_VERSION: 0.67.2

Additional context

I want tofu apply errors to be caught by default (same https://community.gruntwork.io/t/how-to-process-terraform-apply-logs-for-catching-errors-in-ci/656 )

Currently, it just logs unuseful outputs like the following:

04:57:17.253 ERROR  [kafka_admin_ec2] tofu invocation failed in /github/workspace/<path>/.terragrunt-cache/pBa95-l1_fpzkMhLdl_auz2P1_s/vxdbUoFBPPcfo8ey7QUdnvPtOeY/terraform/<module> error=[/github/workspace/terragrunt/dev/kafka_admin_ec2/.terragrunt-cache/pBa95-l1_fpzkMhLdl_auz2P1_s/vxdbUoFBPPcfo8ey7QUdnvPtOeY/terraform/<module>] exit status 1
04:57:17.253 ERROR  [<module>] Module <module> has finished with an error: 1 error occurred:
	* [/github/workspace/terragrunt/dev/<module>/.terragrunt-cache/pBa95-l1_fpzkMhLdl_auz2P1_s/vxdbUoFBPPcfo8ey7QUdnvPtOeY/terraform/<module>] exit status 1

and it's quite hard to debug.

@LittleWat LittleWat added the bug Something isn't working label Sep 26, 2024
@LittleWat LittleWat changed the title fork/exec $GITHUB_WORKSPACE/.github/scripts/tfwrapper.sh: no such file or directory fork/exec $GITHUB_WORKSPACE/.github/scripts/tfwrapper.sh: no such file or directory Sep 26, 2024
@yhakbar
Copy link

yhakbar commented Dec 13, 2024

Is the .github/scripts/tfwrapper.sh file executable?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants