79244479

Date: 2024-12-02 14:45:19
Score: 0.5
Natty:
Report link

My answer is disregarding the context of the original question (which has already been answered in the past), but only focusing on the question in the title:

How to print terraform variable values?

And I want to correct something that is implied by all these other answers, i.e. that a terraform variable can only be retrieved programmatically via the outputs, and thus needing to init+apply first. This is not true.

There is a way to print an actual variable (i.e. from variables.tf and/or terraform.tfvars) It is a bit hidden, there is no direct subcommand designed for this (as opposed to terraform output) but you can do it with this short "one-liner":

terraform console <<EOF
var.<your_variable>
EOF
Reasons:
  • RegEx Blacklisted phrase (1): I want
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Contains question mark (0.5):
Posted by: adamency