terraform output
The command that prints output values from state; -raw prints one bare value for a shell variable and -json prints machine-readable output for programs.
In more detail
Sensitive outputs are hidden in the plain listing, but -raw and -json print them, deliberately, because their purpose is to hand the value to something else. Parse -json in pipelines rather than the human-readable format.
Examples
path=$(terraform output -raw manifest_path)terraform output -jsonRelated terms
- output value — A named value a configuration publishes after apply, declared in an output block, like the return value of a function.
- JSON — A simple text format for structured data made of keys, values, lists and nested objects.
- sensitive value — A variable or output marked sensitive = true, which Terraform hides in plan output and the terminal but still stores in state in plain text.
Taught in
- Return Values: Outputs And Locals — Infrastructure as Code with Terraform
- Input Variables, Outputs, And Which Value Wins — HashiCorp Terraform Associate (004) Exam Prep
- Sensitive Data, Ephemeral Values And Secrets From Vault — HashiCorp Terraform Associate (004) Exam Prep
- Importing What Terraform Did Not Build — HashiCorp Terraform Associate (004) Exam Prep
- Inspecting And Repairing State From The CLI — HashiCorp Terraform Associate (004) Exam Prep
- The Full Mock: Sixty Minutes, Eight Areas, One Plan For The Last Week — HashiCorp Terraform Associate (004) Exam Prep