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

Have an option to only show terraform diffs in Github comment #41

Open
bmckerry opened this issue Dec 28, 2023 · 1 comment
Open

Have an option to only show terraform diffs in Github comment #41

bmckerry opened this issue Dec 28, 2023 · 1 comment
Labels
enhancement New feature or request

Comments

@bmckerry
Copy link

bmckerry commented Dec 28, 2023

Describe the solution you'd like
Right now, having the action do a run-all plan/apply in a high-level dir outputs a lot of unhelpful text - in our case, we use this action to run a plan on one of our entire repos, which outputs >2000 lines of text, <50 of which are the actual change plan.

It'd be nice to have an only_output_diffs option which would only output everything between Terraform will perform the following actions: and Plan: X to add, X to change, X to destroy.

Describe alternatives you've considered
I can try adding a filter to the output text on our end, but not totally sure how I'd go about doing that since the PR commenting happens in the terragrunt-action script.

EDIT: after poking around a little more, I might be able to add this on our end via an INPUT_POST_EXEC_ env var - would be neat to see this as a built-in feature, though.

Additional context
n/a

@bmckerry bmckerry added the enhancement New feature or request label Dec 28, 2023
@bmckerry
Copy link
Author

For now, I worked around the issue by adding this to the GHA env:

INPUT_POST_EXEC_0: |
            IFS=$'\n'
            local -r log_file="${terragrunt_log_file}"
            local terragrunt_log_content=$(cat "${log_file}")
            local terragrunt_output=$(clean_colors "${terragrunt_log_content}")
            local diffs_only_output=""
            local concat_line=false
            for line in $terragrunt_output; do
              if [[ $line == "Terraform used the selected providers to generate the following execution" ]]; then
                concat_line=true
              fi
              if $concat_line; then
                diffs_only_output="${diffs_only_output}\n${line}"
              fi
              if [[ $line == *"Plan:"* ]]; then
                concat_line=false
              fi
            done
            echo "terragrunt output:"
            echo -e $diffs_only_output 2>&1 | tee "${terragrunt_log_file}"
            IFS=$' \t\n'

Maybe there's a better way to handle it, my bash isn't great but it seems to work

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant