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:
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