gruntwork-io / terragrunt

Terragrunt is a flexible orchestration tool that allows Infrastructure as Code written in OpenTofu/Terraform to scale.
https://terragrunt.gruntwork.io/
MIT License
8.06k stars 978 forks source link

Add color to `terragrunt apply` output #404

Open ilyasotkov opened 6 years ago

ilyasotkov commented 6 years ago

It'd be a better user experience if the output of terragrunt apply(-all):

[terragrunt] [/path/to/live] 2018/01/18 05:56:56 Module /path/to/live has finished successfully!

would produce green-colored output when it's a success (exit 0), and red-colored output when it's a failure (exit 1).

Same for terragrunt destroy, of course.

johnparfitt commented 6 years ago

Check this out: https://github.com/coinbase/terraform-landscape

brikis98 commented 6 years ago

That's really cool. Would be great to integrate into Terragrunt :)

davidvasandani commented 6 years ago

@brikis98 I just tested and you can just pipe terragrunt into landscape. terragrunt plan | landscape

brikis98 commented 6 years ago

Sweet!

yuriydee commented 5 years ago

@davidneudorfer Hmm that didnt work for me on MacOS. Piping everything into "landscape" hides all terraform output and I'm just left with terragrunts output. I have the latest version of each tool as well.

[terragrunt] 2019/01/15 12:27:11 Running command: terraform plan
No changes.
davidvasandani commented 5 years ago

@yuriydee I just updated to the latest versions and everything still works.

terragrunt version v0.17.4 Terraform v0.11.11 Terraform Landscape 0.2.2

yuriydee commented 5 years ago

@davidneudorfer I took another look and yeah it actually works. So turns out landscape doesnt work when you have no infra changes and it truncates the output to just one line. But when I am removing/adding resources it works for me with both terraform and terragrunt.

voiski commented 5 years ago

The landscape will require ruby and it will increase my pipeline docker image. I wrote this simple solution to help me for now, at least to help us to see errors and visualize the changes.

terragrunt_color

```bash #!/bin/bash BOLD=$(tput bold) BLACK=$(tput setaf 0) RED=$(tput setaf 1) GREEN=$(tput setaf 2) YELLOW=$(tput setaf 3) BLUE=$(tput setaf 4) CYAN=$(tput setaf 6) RESET=$(tput sgr0) REDBOLD=${RED}${BOLD} REDRESET=${RESET}${RED} BLUEBOLD=${BLUE}${BOLD} BLUERESET=${RESET}${BLUE} terragrunt ${*} 2>&1 | sed \ -e "s/\(\\[terragrunt\\] \\[.*\\]\)\( [0-9\\/]* [0-9:]*\) /${BLUEBOLD}\1${BLUERESET}\2${RESET} /" \ -e "s/\(\\[terragrunt\\]\)\( [0-9\\/]* [0-9:]*\) /${BLUEBOLD}\1${BLUERESET}\2${RESET} /" \ -e "s/\(Error: \)\(.*\)/${REDBOLD}\1${REDRESET}\2${RESET}/" \ -e "s/\(Hit multiple errors:\)/${REDBOLD}\1${RESET}/" \ -e "s/\(exit status 1\)/${RED}\1${RESET}/" \ -e "s/\( WARNING: \)\(.*\)/${YELLOW}${BOLD}\1${RESET}${YELLOW}\2${RESET}/" \ -e "s/\( Running command: \)\(.*\)/\1${CYAN}\2${RESET}/" \ -e "s/\( *.*: *\)\(\".*\"\)\( => \)\(\".*\"\)/${YELLOW}\1${RED}\2${BLACK}\3${GREEN}\4${RESET}/" \ -e "s/\( *.*: *\".*\"\)/${GREEN}\1${RESET}/" ```

./terragrunt_color plan-all