Skip to content

Instantly share code, notes, and snippets.

@imranismail
Last active August 1, 2024 23:38
Show Gist options
  • Save imranismail/3364db5b49200247ca8cb675c96589fe to your computer and use it in GitHub Desktop.
Save imranismail/3364db5b49200247ca8cb675c96589fe to your computer and use it in GitHub Desktop.
An AWK script that supresses terraform helm_release metadata attributes

Motivation

The terraform helm provider is rather noisy printing unnecessary metadata in the plan output making it hard to review changes. This awk script redacts unnecessary field from the output to make it easier to review.

Usage

terraform plan -out plan.tfplan | awk -f supress_helm_release.awk
terraform show -no-color plan.tfplan | awk -f supress_helm_release.awk
BEGIN { in_block = 0; redact = 0 }
/^(\[0m)? (\[3[123]m)?[~+-](\[0m\[0m)? resource "helm_release" "[a-zA-Z0-9_-]+" {$/ { in_block = 1; print; next }
in_block && /^ }$/ { in_block = 0; redact = 0; print; next }
in_block && /^ (\[3[123]m)?[~+-](\[0m\[0m)? (metadata|values) +=/ { redact = 1; next }
in_block && redact && /^ (\[3[123]m)?[~+-](\[0m\[0m)? [a-zA-Z0-9_-]+/ { redact = 0; print; next }
redact { next }
{ print }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment