Commit Graph

25130 Commits

Author SHA1 Message Date
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
Martin Atkins 9f9f22091e backend/remote: Unlock workspace if Context fails
Previously any error case in the Context method would cause us to leave
the remote workspace locked on exit, requiring manual action to unlock it.
2019-10-31 09:45:50 -07:00
James Bardin 2c3c011f20 change state dependencies to AbsResource addrs
We need to be able to reference all possible dependencies for ordering
when the configuration is no longer present, which means that absolute
addresses must be used. Since this is only to recreate the proper
ordering for instance destruction, only resources addresses need to be
listed rather than individual instance addresses.
2019-10-30 17:25:53 -04:00
Chris Griggs 74249a8c23
Merge pull request #23235 from hashicorp/cgriggs01-cherryservers
[Website] CherryServer doc links
2019-10-30 11:16:51 -07:00
cgriggs01 e3b18cd0d9 [Website] CherryServer doc links 2019-10-30 10:55:01 -07:00
James Bardin cd7c3e4231 update CHANGELOG.md 2019-10-30 11:04:51 -04:00
James Bardin 7829a4f6ce
Merge pull request #23215 from hashicorp/jbardin/for-each-self
Resource value may be an object in self evaluation
2019-10-29 12:58:25 -04:00
James Bardin 3839405d3d correctly evaluate self in for_each resources
The fallback type for GetResource from an EachMap is a cty.Object,
because resource schemas may contain dynamically typed attributes.
Check for an Object type in the evaluation of self, to use the proper
GetAttr method when extracting the value.
2019-10-29 12:44:42 -04:00
James Bardin f11c836181 failing test with for_each self reference 2019-10-29 12:14:30 -04:00
Martin Atkins ce68b4d27c config: Remove legacy interpolation function implementations
These are often confusing for new contributors, since this looks
suspiciously like the right place to add new functions or change the
behavior of existing ones.

To reduce that confusion, here we remove them entirely from this package
(which is now dead code in Terraform 0.12 anyway) and include in the
documentation comments a pointer to the current function implementations.
2019-10-29 08:25:45 -07:00
Martin Atkins f8a32f0b83 website: Consistently recommend the required_providers block
Previously we were inconsistent in whether we were recommending the
new required_providers block or the "version" setting inside a "provider"
block.
2019-10-28 15:56:12 -07:00
Martin Atkins 7c110f9cf8 website: provider version constraints in modules 2019-10-28 15:56:12 -07:00
Thomas Alton ddd0d2a442 website: Provider proxy config only supports alias 2019-10-28 15:56:12 -07:00
Thomas Alton 24386bcfcb website: Link to `required_providers` block from provider documentation 2019-10-28 15:56:12 -07:00
Colby Rome d58d91a6b2 website: Fix a missing word in the Module Composition page 2019-10-28 15:19:26 -07:00
Pam Selle e44800a696
Merge pull request #23209 from pselle/docs-address
Quote differently so render works on taint docs
2019-10-28 16:56:44 -04:00
Chris Griggs 334c8e9dbb
Merge pull request #23212 from hashicorp/cgriggs01-dome9-links
[Website] Dome9 provider links
2019-10-28 13:22:44 -07:00
Justin Campbell 07624eeb31
website: Add Terraform Registry Provider Docs page (#23139)
Co-Authored-By: Kim Ngo <kngo@hashicorp.com>
Co-Authored-By: Nick Fagerlund <nick@hashicorp.com>
2019-10-28 16:05:22 -04:00
cgriggs01 7e53919912 [Website] Dome9 provider links 2019-10-28 10:45:25 -07:00
Pam Selle 22ae5cf52d Quote differently so render works 2019-10-28 13:04:38 -04:00
Chris Griggs 8a34c33ad3
Merge pull request #23183 from hashicorp/cgriggs01-vultr-links
[Website] Vultr provider links
2019-10-24 13:20:08 -07:00
Pam Selle 5b453f6ba9
Merge pull request #23186 from pselle/pselle/docs-syntax-link
Docs around splat and for_each
2019-10-24 16:15:18 -04:00
Pam Selle 566f22a34e Docs around splat 2019-10-24 16:09:34 -04:00
scott1138 c6baf28508
Update taint docs - for_each
Provide an explanation of how to taint a resource created with for_each
2019-10-24 14:53:45 -05:00
Chris Griggs 7dac6eed82
Update fix 2019-10-24 12:03:43 -07:00
cgriggs01 67105ceeae [Website] Vultr provider links 2019-10-24 12:00:35 -07:00
James Bardin 744b835e17
Merge pull request #22937 from hashicorp/jbardin/cbd-modules
create_before_destroy across modules
2019-10-24 12:23:01 -04:00
James Bardin f766bb8380 prune unused resources from apply
If a resource is only destroying instances, there is no reason to
prepare the state and we can remove the Resource (prepare state) nodes.
They normally have pose no issue, but if the instances are being
destroyed along with their dependencies, the resource node may fail to
evaluate due to the missing dependencies (since destroy happens in the
reverse order).

These failures were previously blocked by there being a cycle when the
destroy nodes were directly attached to the resource nodes.
2019-10-24 12:04:46 -04:00
James Bardin 7108560228 failing test with destroy cycle
after the previous commit the cycle is broken, but we can't evaluate
resource counts that depends on data sources being destroyed.
2019-10-24 12:04:46 -04:00
James Bardin eb6e7bba2e do not connect destroy and resource nodes
Destroy nodes do not need to be connected to the resource (prepare
state) node when adding them to the graph. Destroy nodes already have a
complete state in the graph (which is being destroyed), any references
will be added in the ReferenceTransformer, and the proper
connection to the create node will be added in the
DestroyEdgeTransformer.

Under normal circumstances this makes no difference, as create and
destroy nodes always have an dependency, so having the prepare state
handled before both only linearizes the operation slightly in the
normal destroy-then-create scenario.

However if there is a dependency on a resource being replaced in another
module, there will be a dependency between the destroy nodes in each
module (to complete the destroy ordering), while the resource node will
depend on the variable->output->resource chain. If both the destroy and
create nodes depend on the resource node, there will be a cycle.
2019-10-24 12:04:46 -04:00
James Bardin 3eb0e74ef9 failing test for module instance replace cycle
Destroy-time references are not correctly or fully inverted when
crossing module boundaries, causing cycle during apply.
2019-10-24 12:04:46 -04:00
Pam Selle 491a739659
Update CHANGELOG.md 2019-10-24 12:04:23 -04:00
James Bardin 470362b051 fix CBD tests to work on real data
The CBDEdgeTransformer tests worked on fake data structures, with a
synthetic graph, and configs that didn't match. Update them to generate
a more complete graph, with real node implementations, from real
configs.

The output graph is filtered down to instances, and the results still
functionally match the original expected test results, with some minor
additions due to using the real implementation.
2019-10-24 12:01:50 -04:00
James Bardin 8f35984791 Use Descendants rather than UpEdges in CBD
When looking for dependencies to fix when handling
create_before_destroy, we need to look past more than one edge, as
dependencies may appear transitively through outputs and variables. Use
Descendants rather than UpEdges.

We have the full graph to use for the CBD transformation, so there's no
longer any need to create a temporary graph, which may differ from the
original.
2019-10-24 12:01:50 -04:00
James Bardin 7c703b1bbf apply edge transforamtions after references
We can't correctly resolve the destroy ordering if all references
haven't been assigned to each node.
2019-10-24 12:01:50 -04:00
Pam Selle cca36025d6
Merge pull request #22946 from hashicorp/kmoe/copy_dir_dotfiles
remove dotfile exclusion in copyDir
2019-10-24 12:01:42 -04:00
Pam Selle 9ee19eac94
Merge pull request #23177 from hashicorp/pselle/docs-syntax-link
Fix link in syntax docs
2019-10-24 11:59:08 -04:00
Pam Selle 0d4ea7d9ad Fix link in syntax docs 2019-10-24 11:57:08 -04:00
Kris Luminar 8bb0491dc1 website: clarify where you run the `terraform init` command 2019-10-24 08:41:00 -07:00
charlottemach e3d38046dc website/docs: replace outdated tag syntax (#23111)
Fixes #21614
2019-10-24 11:23:17 -04:00
Pam Selle 90ecd17bd5 Fix err test 2019-10-23 14:04:39 -04:00
Pam Selle 8f04ab3eaf
Merge pull request #23157 from pselle/each-err
Add a special error when each.value is nil in for_each resources
2019-10-23 11:19:39 -04:00
Pam Selle 86d69bbe18 Tweak the message mildly 2019-10-23 11:18:10 -04:00
Pam Selle 13ff341447 Add a special error for each.value 2019-10-22 15:44:28 -04:00
Chris Griggs d7bce857cf
Merge pull request #23125 from hashicorp/cgriggs01-launchdarkly
[Website] LaunchDarkly provider links
2019-10-21 11:48:56 -07:00
Chris Griggs d7df6ce642
Merge pull request #23123 from hashicorp/cgriggs01-community
[Website] Update community providers
2019-10-21 11:48:02 -07:00
Martin Atkins baa49f43c8
go.mod: We only expect Go 1.12
This was erroneously updated by some earlier operation, but
Terraform Core is still targeting only Go 1.12 for the moment.
2019-10-18 16:37:34 -07:00
cgriggs01 5452844c58 [Website] LaunchDarkly provider links 2019-10-18 14:07:36 -07:00
tf-release-bot bac0577c70 Cleanup after v0.12.12 release 2019-10-18 18:50:39 +00:00
tf-release-bot ade49ebca7
v0.12.12 2019-10-18 18:39:16 +00:00