diff --git a/modules/terraform/cmd.go b/modules/terraform/cmd.go index c6c5d2380..ea4baf511 100644 --- a/modules/terraform/cmd.go +++ b/modules/terraform/cmd.go @@ -60,6 +60,8 @@ func GetCommonOptions(options *Options, args ...string) (*Options, []string) { } _, tgLogSet := options.EnvVars["TERRAGRUNT_LOG_FORMAT"] if !tgLogSet { + // key-value format for terragrunt logs to avoid colors and have plain form + // https://terragrunt.gruntwork.io/docs/reference/cli-options/#terragrunt-log-format options.EnvVars["TERRAGRUNT_LOG_FORMAT"] = "key-value" } _, tgLogFormat := options.EnvVars["TERRAGRUNT_LOG_CUSTOM_FORMAT"] diff --git a/modules/terraform/output.go b/modules/terraform/output.go index 93a2ed299..b4b67ec7b 100644 --- a/modules/terraform/output.go +++ b/modules/terraform/output.go @@ -16,8 +16,10 @@ import ( const skipJsonLogLine = " msg=" var ( + // ansiLineRegex matches lines starting with ANSI escape codes for text formatting (e.g., colors, styles). ansiLineRegex = regexp.MustCompile(`(?m)^\x1b\[[0-9;]*m.*`) - tgLogLevel = regexp.MustCompile(`.*time=\S+ level=\S+ prefix=\S+ binary=\S+ msg=.*`) + // tgLogLevel matches log lines containing fields for time, level, prefix, binary, and message, each with non-whitespace values. + tgLogLevel = regexp.MustCompile(`.*time=\S+ level=\S+ prefix=\S+ binary=\S+ msg=.*`) ) // Output calls terraform output for the given variable and return its string value representation.