Terraform: Display Outputs

less than 1 minute read

Description:

By default, Terraform will display outputs during a terraform plan or apply, but follow this step if you need it to display a secret variable’s output.

To Resolve:

  1. Let’s say you have a private key you need to connect to a linux server after creation.

    • inside outputs.tf you have:
    1
    2
    3
    4
    
    output "tls_private_key" {
       value     = tls_private_key.vm_ssh_key.private_key_pem
       sensitive = true
    }
    
  2. Then in your pipeline, just add this step after the terraform apply command:

    1
    2
    
    - script: terraform output -raw tls_private_key
       displayName: 'terraform display key'
    

Comments