You cannot show secret values (either attribute set as sensitive by the provider, or variables or outputs which are declared as secret in the configuration) in the UI, but they are still encoded in the plan (or statefile).
One way to see the full change, including any secrets, is to output the plan to a file and inspect that.
Here’s an example configuration with a (user-defined) sensitive value:
variable "sensitive" {
default = "secret"
sensitive = true
}
resource "random_pet" "secret" {
prefix = var.sensitive
}
now I run terraform plan, and save the plan to a file called tf.plan:
terraform plan -out tf.plan
An execution plan has been generated and is shown below.
Resource actions are indicated with the following symbols:
+ create
Terraform will perform the following actions:
# random_pet.secret will be created
+ resource "random_pet" "secret" {
+ id = (known after apply)
+ length = 2
+ prefix = (sensitive)
+ separator = "-"
}
Plan: 1 to add, 0 to change, 0 to destroy.
------------------------------------------------------------------------
This plan was saved to: tf.plan
To perform exactly these actions, run the following command to apply:
terraform apply "tf.plan"
And then I’ll use terraform show -json
to see the full plan, including that sensitive prefix
(this is a small snippet of the output, piped through jq for pretty printing):
terraform show -json tf.plan | jq
{
/// truncated output
"planned_values": {
"root_module": {
"resources": [
{
"address": "random_pet.secret",
"mode": "managed",
"type": "random_pet",
"name": "secret",
"provider_name": "registry.terraform.io/hashicorp/random",
"schema_version": 0,
"values": {
"keepers": null,
"length": 2,
"prefix": "secret",
"separator": "-"
}
}
]
}
},
}
terraform show -json also lets you examine the contents of statefiles, not just plans.