Commit Graph

2643 Commits

Author SHA1 Message Date
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
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
90ecd17bd5 Fix err test 2019-10-23 14:04: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
Radek Simko
7860f55e4f
Version tools per Go convention under tools.go 2019-10-17 22:23:39 +02:00
Martin Atkins
e21f0fa61e backend/local: Handle interactive prompts for variables in UI layer
During the 0.12 work we intended to move all of the variable value
collection logic into the UI layer (command package and backend packages)
and present them all together as a unified data structure to Terraform
Core. However, we didn't quite succeed because the interactive prompts
for unset required variables were still being handled _after_ calling
into Terraform Core.

Here we complete that earlier work by moving the interactive prompts for
variables out into the UI layer too, thus allowing us to handle final
validation of the variables all together in one place and do so in the UI
layer where we have the most context still available about where all of
these values are coming from.

This allows us to fix a problem where previously disabling input with
-input=false on the command line could cause Terraform Core to receive an
incomplete set of variable values, and fail with a bad error message.

As a consequence of this refactoring, the scope of terraform.Context.Input
is now reduced to only gathering provider configuration arguments. Ideally
that too would move into the UI layer somehow in a future commit, but
that's a problem for another day.
2019-10-10 10:07:01 -07:00
Martin Atkins
564b57b1f6 core: Require variables correctly set during NewContext
We previously deferred this to Validate, but all of our operations require
a valid set of variables and so checking this up front makes it more
obvious when a call into Terraform Core from the CLI layer isn't
populating variables correctly, instead of having it fail downstream
somewhere.

It's the caller's responsibility to ensure that it has collected values
for all of the variables in some way before calling NewContext, because
in the main case driven by the CLI there are many different places that
variable values can be collected from and so handling the main user-facing
validation in the CLI allows us to return better error messages that take
into account which way a variable is (or is not) being set.
2019-10-10 10:07:01 -07:00
James Bardin
1ee851f256
Merge pull request #22846 from hashicorp/jbardin/evaluate-resource
Always evaluate resources in their entirety
2019-10-08 07:57:15 -04:00
Pam Selle
43c66c2048
Merge pull request #22811 from notchairmk/b-apply-node-removed-targeted
bug: fix terraform trying to clean up orphan modules on target
2019-10-07 16:04:50 -04:00
Martin Atkins
39e609d5fd vendor: switch to HCL 2.0 in the HCL repository
Previously we were using the experimental HCL 2 repository, but now we'll
shift over to the v2 import path within the main HCL repository as part of
actually releasing HCL 2.0 as stable.

This is a mechanical search/replace to the new import paths. It also
switches to the v2.0.0 release of HCL, which includes some new code that
Terraform didn't previously have but should not change any behavior that
matters for Terraform's purposes.

For the moment the experimental HCL2 repository is still an indirect
dependency via terraform-config-inspect, so it remains in our go.sum and
vendor directories for the moment. Because terraform-config-inspect uses
a much smaller subset of the HCL2 functionality, this does still manage
to prune the vendor directory a little. A subsequent release of
terraform-config-inspect should allow us to completely remove that old
repository in a future commit.
2019-10-02 15:10:21 -07:00
James Bardin
aacfaa4fd7 ensure data sources are always written to state
The old logic for `depends_on` was to short-circuit evaluation of the
data source, but that prevented a plan and state from being recorded.
Use the (currently unused) ForcePlanRead to ensure that the plan is
recorded when the config contains `depends_on`.

This does not fix the fact that depends on does not work with data
sources, and will still produce a perpetual diff. This is only to fix
evaluation errors when an indexed data source is evaluated during
refresh.
2019-09-24 17:47:01 -04:00
Kristin Laemmert
54661ec1df
command/import: fix error during import when implied provider was not used (#22855)
* command/import: properly use `-provider` supplied on the command line

The import command now attaches the provider configuration in the resource
instance, if set. That config is attached to the NodeAbstractResource
during the import graph building. This prevents errors when the implied
provider is not actually in the configuration at all, which may happen
when a configuration is using the `-beta` version of a provider (and
only that `-beta` version).

* command/import: fix variable reassignment and update docs

Fixes #22564
2019-09-20 10:02:42 -04:00
James Bardin
fed4e82c25 check resource config for unknowns during apply
Now that the most common cause of unknowns (invalid resource indexes) is
caught earlier, we can validate that the final apply config is wholly
known before attempting to apply it. This ensures that we're applying
the configuration we intend, and not silently dropping values.
2019-09-19 11:46:09 -04:00
James Bardin
da8ec6b483 change state eval GetResource to return all
Always return the entire resource object from
evaluationStateData.GetResource, rather than parsing the references for
individual instances. This allows for later evaluation of resource
indexes so we can return errors when they don't exist, and prevent
errors when short-circuiting around invalid indexes in conditionals.
2019-09-19 09:23:12 -04:00
James Bardin
86bf674246 change GetResourceInstance to GetResource
In order to allow lazy evaluation of resource indexes, we can't index
resources immediately via GetResourceInstance. Change the evaluation to
always return whole Resources via GetResource, and index individual
instances during expression evaluation.

This will allow us to always check for invalid index errors rather than
returning an unknown value and ignoring it during apply.
2019-09-19 09:19:14 -04:00
Martin Atkins
7e29b9b5d4 core: Warn when creating and applying with -target
The documentation for the -target option warns that it's intended for
exceptional circumstances only and not for routine use, but that's not a
very prominent location for that warning and so some users miss it.

Here we make the warning more prominent by including it directly in the
Terraform output when -target is in use. We first warn during planning
that the plan might be incomplete, and then warn again after apply
concludes and direct the user to run "terraform plan" to make sure that
there are no further changes outstanding. The latter message is intended
to reinforce that -target should only be a one-off operation and that you
should always run without it soon after to ensure that the workspace is
left in a consistent, converged state.
2019-09-17 14:36:05 -07:00
Taylor Chaparro
cfcc878c2d NodeModuleRemoved implements RemovableIfNotTargeted 2019-09-16 08:47:22 -07:00
Pam Selle
80dec63917
Merge pull request #22691 from pselle/customizediff
Evaluate ignore changes before sending plan to CustomizeDiff
2019-09-11 14:45:21 -04:00
Pam Selle
4f198fc797
Merge pull request #22760 from pselle/add-source-to-diag-for_each
Add source addressing to make error more useful
2019-09-11 09:36:24 -04:00
Pam Selle
3be3e3c089 Add source addressing to make error more useful 2019-09-10 14:56:11 -04:00
Pam Selle
a25abbe7d8 Cover empty sets 2019-09-10 10:57:35 -04:00
Pam Selle
c8dd5d3923 add a comment 2019-09-09 09:35:11 -04:00
Pam Selle
de531fd2c9 Remove dead code 2019-09-09 09:35:11 -04:00
Pam Selle
bafd8ced7c Put back in old spot 2019-09-09 09:35:11 -04:00
Pam Selle
96d84da032 Do ignore changes processing again after plan, in case strange things are done during plan that should not be 2019-09-09 09:35:10 -04:00
Pam Selle
2e5a8c0f6e Update when ignore_changes are evaluated, to impact customizediff 2019-09-09 09:35:10 -04:00
James Bardin
102c575f04 don't send an invalid config to a provisioner
The config diagnostics weren't checked before sending to the
provisioner, and may have contained invalid values.
2019-09-06 17:42:53 -04:00
James Bardin
a94f5ee132 prevent panics when encountering nil diffs
While we can't change the behavior of helper/schema at this point, we
can protect against panics in the case of unexpected nils in the
instance diff.
2019-09-04 16:51:42 -04:00
Pam Selle
37e8147c4f Spiffy comment 2019-08-28 15:13:36 -04:00
Pam Selle
35016a5ea3 Move things around, add test for resource references 2019-08-28 14:02:11 -04:00
Pam Selle
0f3d8b4884 More explicit err testing 2019-08-26 15:30:42 -04:00
Pam Selle
cce35e4a36 update name 2019-08-26 15:27:07 -04:00
Pam Selle
a4d2bf45fc Update tests, plan test is able to reproduce panic without fix 2019-08-26 15:25:03 -04:00
Pam Selle
0eb7cfd0d9 Check for wholly known for forEach evaluation, add some tests 2019-08-26 15:16:25 -04:00
James Bardin
b1025a9d29 update tests to reflect correct provisioners
We no longer create new provisioners for every module.
2019-08-21 19:41:56 -04:00
James Bardin
2b4695eecb only create one provisioner instance per type
There's no reason to start individual provisioners per module path, as
they are not configured per module (or independently at all for that
matter).
2019-08-21 19:41:56 -04:00
Pam Selle
901ec990ed
Merge pull request #22156 from binlab/feature/bastion-ca-ssh
Add SSH certificate authentication method for connection via Bastion
2019-08-15 16:01:54 -04:00
Pam Selle
e2931763bf
Merge pull request #22454 from pselle/nokeymoregraph
Add edge when calculating for_each orphans
2019-08-13 17:35:20 -04:00
Pam Selle
e6817f6319 Reordering, comment update 2019-08-13 17:22:14 -04:00
Pam Selle
06e72c693f Add test 2019-08-13 16:31:07 -04:00
Pam Selle
6fae69f07b Creating the node would be nice 2019-08-13 10:38:52 -04:00
Pam Selle
b9fa724273 Add edge 2019-08-13 10:24:26 -04:00
Pam Selle
3662dbc03d Ensure no key added to graph first 2019-08-13 10:10:36 -04:00
Radek Simko
98a796c3a3
Merge pull request #22272 from hashicorp/f-httpclient-ua
httpclient: Introduce composable UserAgent()
2019-08-12 20:20:03 +01:00
Alex Pilon
07d6289701
add comment noting deprecated type 2019-08-08 11:14:26 -04:00
Alex Pilon
77757d9f5b
prune references to config/module
delete config/module
prune references to config except in terraform/resource.go
move, cleanup, and delete inert code
2019-08-07 17:50:59 -04:00
Alex Pilon
4bf43efcfd
move hcl2shim package to configs 2019-08-06 19:58:58 -04:00