opentofu/backend/remote
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
..
testdata clean up go mod for go-tfe 2019-09-27 14:16:41 -07:00
backend_apply_test.go Standardise directory name for test data 2019-06-30 10:16:15 +02:00
backend_apply.go backend/remote: Report invalid variables only remotely 2019-10-18 11:31:19 -07:00
backend_common.go backend/remote: Report invalid variables only remotely 2019-10-18 11:31:19 -07:00
backend_context_test.go backend/remote: Support HCL variable values in local operations 2019-10-31 09:45:50 -07:00
backend_context.go backend/remote: Support HCL variable values in local operations 2019-10-31 09:45:50 -07:00
backend_mock.go vendor latest go-tfe 2019-09-27 15:13:40 -07:00
backend_plan_test.go vendor latest go-tfe 2019-09-27 15:13:40 -07:00
backend_plan.go backend/remote: Report invalid variables only remotely 2019-10-18 11:31:19 -07:00
backend_state_test.go backend/remote: cleanup test connections 2019-02-07 09:55:19 +01:00
backend_state.go backend/remote: do not unlock after a failed upload 2019-04-29 21:23:33 +02:00
backend_test.go Replace import paths & set UA string where necessary 2019-10-11 22:40:54 +01:00
backend.go Replace import paths & set UA string where necessary 2019-10-11 22:40:54 +01:00
cli.go Change how to fall back from remote to local backend 2018-11-20 22:25:52 +01:00
colorize.go backend/remote: implement the Local interface 2018-11-26 20:50:25 +01:00
remote_test.go Change how to fall back from remote to local backend 2018-11-20 22:25:52 +01:00
testing.go Replace import paths & set UA string where necessary 2019-10-11 22:40:54 +01:00