cloudposse-archives / tfmask

Terraform utility to mask select output from `terraform plan` and `terraform apply`
https://cloudposse.com/accelerate
Apache License 2.0
202 stars 27 forks source link

Unable to mask inside yaml block. #35

Open vishnu-techprescient-teika opened 9 months ago

vishnu-techprescient-teika commented 9 months ago

Hi, I am trying to test with kubectl manifest file, but tfmask is not working.

Without tfmask
Terraform will perform the following actions:

  # kubectl_manifest.test will be updated in-place
  ~ resource "kubectl_manifest" "test" {
        id                      = "/api/v1/namespaces/default/configmaps/vishnu-test-demo"
        name                    = "vishnu-test-demo"
      ~ yaml_body               = (sensitive value)
      ~ yaml_body_parsed        = <<-EOT
            apiVersion: v1
            data:
          -   password: ijMmsd1piZwz
          +   password: ijMms1piZwz_paa
            kind: ConfigMap
            metadata:
              name: vishnu-test-demo
        EOT
        # (12 unchanged attributes hidden)
    }

Plan: 0 to add, 1 to change, 0 to destroy.
With tfmask
Terraform will perform the following actions:

  # kubectl_manifest.test will be updated in-place
  ~ resource "kubectl_manifest" "test" {
        id                      = "######################################################"
        name                    = "vishnu-test-demo"
      ~ yaml_body               = (sensitive value)
      ~ yaml_body_parsed        = <<-EOT
            apiVersion: v1
            data:
          -   password: ijMmsd1piZwz
          +   password: ijMms1piZwz_paa
            kind: ConfigMap
            metadata:
              name: vishnu-test-demo
        EOT
        # (12 unchanged attributes hidden)
    }

Plan: 0 to add, 1 to change, 0 to destroy.

My env params:

export TFMASK_CHAR="#"                                                                                                       
export TFMASK_VALUES_REGEX="(?i)^.*(oauth|secret|token|password|key|result|id).*$"

command : terraform plan -var-file=staging.tfvars -no-color | tfmask

Expected was to also mask the password section

I am using macos and build the latest release 0.7.0 from source.