From f61a34231143f302e1c05ed295adbe6cb6e0aac9 Mon Sep 17 00:00:00 2001 From: Pam Selle <204372+pselle@users.noreply.github.com> Date: Wed, 28 Oct 2020 15:46:09 -0400 Subject: [PATCH] Hide sensitive outputs in terraform show --- command/format/state.go | 6 +++++- command/format/state_test.go | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/command/format/state.go b/command/format/state.go index 6d6e2cee22..e737f3a00d 100644 --- a/command/format/state.go +++ b/command/format/state.go @@ -74,7 +74,11 @@ func State(opts *StateOpts) string { for _, k := range ks { v := m.OutputValues[k] p.buf.WriteString(fmt.Sprintf("%s = ", k)) - p.writeValue(v.Value, plans.NoOp, 0) + if v.Sensitive { + p.buf.WriteString("(sensitive value)") + } else { + p.writeValue(v.Value, plans.NoOp, 0) + } p.buf.WriteString("\n") } } diff --git a/command/format/state_test.go b/command/format/state_test.go index d7864ee162..5d83200bcf 100644 --- a/command/format/state_test.go +++ b/command/format/state_test.go @@ -219,7 +219,7 @@ map_var = { "first" = "foo" "second" = "bar" } -sensitive_var = "secret!!!" +sensitive_var = (sensitive value) string_var = "string value"` func basicState(t *testing.T) *states.State {