nerdexam
HashiCorp

TA-002-P · Question #203

Mary has created a database instance in AWS and for ease of use is outputting the value of the database password with the following code: 1. output "db_password" 2. { 3. value = local.db_password 4…

The correct answer is B. Use sensitive parameter. Terraform's sensitive = true output argument suppresses the value from appearing in CLI output after terraform apply.

Use the Terraform CLI (terraform plan, apply, destroy, fmt, init, validate, workspace, import, taint, providers, output)

Question

Mary has created a database instance in AWS and for ease of use is outputting the value of the database password with the following code: 1. output "db_password" 2. { 3. value = local.db_password 4. } Mary wants to hide the output value in the CLI after terraform apply? What is the best way?

Options

  • AUse secure parameter
  • BUse sensitive parameter
  • CUse cryptographic hash
  • DEncrypt the value using encrypt() function

How the community answered

(44 responses)
  • A
    11% (5)
  • B
    77% (34)
  • C
    2% (1)
  • D
    9% (4)

Why each option

Terraform's `sensitive = true` output argument suppresses the value from appearing in CLI output after `terraform apply`.

AUse secure parameter

`secure` is not a valid Terraform output block argument; no such parameter exists in the Terraform language.

BUse sensitive parameterCorrect

Adding `sensitive = true` to an output block marks the value as sensitive, causing Terraform to redact it in CLI output and plan diffs, displaying `(sensitive value)` instead. This is the built-in, idiomatic Terraform mechanism for hiding secrets like database passwords without altering the underlying value.

CUse cryptographic hash

Using a cryptographic hash would transform the value permanently and would not allow downstream consumers to retrieve the original password; it is not a Terraform output feature.

DEncrypt the value using encrypt() function

Terraform does not provide an `encrypt()` built-in function; encryption logic must be handled externally and is not how sensitive outputs are suppressed in the CLI.

Concept tested: Sensitive output values suppression in Terraform

Source: https://developer.hashicorp.com/terraform/language/values/outputs#sensitive-suppressing-values-in-cli-output

Topics

#Terraform outputs#Sensitive data handling#CLI display#Output configuration

Community Discussion

No community discussion yet for this question.

Full TA-002-P Practice