terraform/backend
Martin Atkins 8f27409007 backend/remote: Support HCL variable values in local operations
For remote operations, the remote system (Terraform Cloud or Enterprise)
writes the stored variable values into a .tfvars file before running the
remote copy of Terraform CLI.

By contrast, for operations that only run locally (like
"terraform import"), we fetch the stored variable values from the remote
API and add them into the set of available variables directly as part
of creating the local execution context.

Previously in the local-only case we were assuming that all stored
variables are strings, which isn't true: the Terraform Cloud/Enterprise UI
allows users to specify that a particular variable is given as an HCL
expression, in which case the correct behavior is to parse and evaluate
the expression to obtain the final value.

This also addresses a related issue whereby previously we were forcing
all sensitive values to be represented as a special string "<sensitive>".
That leads to type checking errors for any variable specified as having
a type other than string, so instead here we use an unknown value as a
placeholder so that type checking can pass.

Unpopulated sensitive values may cause errors downstream though, so we'll
also produce a warning for each of them to let the user know that those
variables are not available for local-only operations. It's a warning
rather than an error so that operations that don't rely on known values
for those variables can potentially complete successfully.

This can potentially produce errors in situations that would've been
silently ignored before: if a remote variable is marked as being HCL
syntax but is not valid HCL then it will now fail parsing at this early
stage, whereas previously it would've just passed through as a string
and failed only if the operation tried to interpret it as a non-string.
However, in situations like these the remote operations like
"terraform plan" would already have been failing with an equivalent
error message anyway, so it's unlikely that any existing workspace that
is being used for routine operations would have such a broken
configuration.
2019-10-31 09:45:50 -07:00
..
atlas Change backend.ValidateConfig to PrepareConfig 2019-02-25 18:37:20 -05:00
init Replace import paths & set UA string where necessary 2019-10-11 22:40:54 +01:00
local Version tools per Go convention under tools.go 2019-10-17 22:23:39 +02:00
remote backend/remote: Support HCL variable values in local operations 2019-10-31 09:45:50 -07:00
remote-state vendor: switch to HCL 2.0 in the HCL repository 2019-10-02 15:10:21 -07:00
backend.go backend: Allow certain commands to opt out of required variable checks 2019-10-10 10:07:01 -07:00
cli.go backend: Update interface and implementations for new config loader 2018-10-16 18:39:12 -07:00
nil.go Change backend.ValidateConfig to PrepareConfig 2019-02-25 18:37:20 -05:00
nil_test.go backend: introduce the backend set of interfaces 2017-01-26 14:33:49 -08:00
operation_type.go Version tools per Go convention under tools.go 2019-10-17 22:23:39 +02:00
operationtype_string.go stringer: Regenerate files with latest version 2019-05-13 15:34:27 +01:00
testing.go vendor: switch to HCL 2.0 in the HCL repository 2019-10-02 15:10:21 -07:00
unparsed_value.go backend/remote: Report invalid variables only remotely 2019-10-18 11:31:19 -07:00
unparsed_value_test.go backend/local: Handle interactive prompts for variables in UI layer 2019-10-10 10:07:01 -07:00