Commit Graph

26036 Commits

Author SHA1 Message Date
James Bardin 3046b790b1
Merge pull request #25018 from hashicorp/jbardin/destroy-modules
Destroy nested, expanding modules
2020-05-29 12:44:13 -04:00
Kristin Laemmert 020084f6d0 update e2etests for windows compatibility 2020-05-29 11:57:50 -04:00
Alisdair McDiarmid 83482770c4
Merge pull request #25055 from hashicorp/alisdair/detected-legacy-provider-on-init
command/init: Better diagnostics for provider 404s
2020-05-29 11:57:18 -04:00
Martin Atkins fd26df0bc4
Update CHANGELOG.md 2020-05-29 07:42:46 -07:00
Martin Atkins 89c2a61b41 website: Small corrections to the "plan" and "apply" command docs
The "apply" documentation contained a simple typo, while the "plan"
documentation contained outdated information about using
"terraform plan PLANFILE" to view a plan. The latter is now a separate
command entirely, since Terraform 0.12: "terraform show PLANFILE".
2020-05-29 07:36:40 -07:00
Martin Atkins 31a4b44d2e backend/local: treat output changes as side-effects to be applied
This is a baby-step towards an intended future where all Terraform actions
which have side-effects in either remote objects or the Terraform state
can go through the plan+apply workflow.

This initial change is focused only on allowing plan+apply for changes to
root module output values, so that these can be written into a new state
snapshot (for consumption by terraform_remote_state elsewhere) without
having to go outside of the primary workflow by running
"terraform refresh".

This is also better than "terraform refresh" because it gives an
opportunity to review the proposed changes before applying them, as we're
accustomed to with resource changes.

The downside here is that Terraform Core was not designed to produce
accurate changesets for root module outputs. Although we added a place for
it in the plan model in Terraform 0.12, Terraform Core currently produces
inaccurate changesets there which don't properly track the prior values.

We're planning to rework Terraform Core's evaluation approach in a
forthcoming release so it would itself be able to distinguish between the
prior state and the planned new state to produce an accurate changeset,
but this commit introduces a temporary stop-gap solution of implementing
the logic up in the local backend code, where we can freeze a snapshot of
the prior state before we take any other actions and then use that to
produce an accurate output changeset to decide whether the plan has
externally-visible side-effects and render any changes to output values.

This temporary approach should be replaced by a more appropriately-placed
solution in Terraform Core in a release, which should then allow further
behaviors in similar vein, such as user-visible drift detection for
resource instances.
2020-05-29 07:36:40 -07:00
James Bardin 1bbb59fc1b remove extra whitespace 2020-05-29 10:31:10 -04:00
James Bardin acd3dca567 remove unused closer field 2020-05-29 10:29:27 -04:00
James Bardin 3dbd6ea3a9 remove stale comment 2020-05-29 10:18:33 -04:00
Alisdair McDiarmid cdfc2e9abd
Merge pull request #25065 from hashicorp/alisdair/remove-dead-code-plugin-discovery
plugin/discovery: Remove dead code
2020-05-29 10:18:15 -04:00
James Bardin 46d27fe848 update CHANGELOG.md 2020-05-28 22:34:13 -04:00
James Bardin 9cb7851b02 update CHANGELOG.md 2020-05-28 22:33:21 -04:00
James Bardin 74ae34865d re-add test lost in merge 2020-05-28 21:41:15 -04:00
James Bardin b860b40127 re-enable depend_on test 2020-05-28 21:35:05 -04:00
James Bardin 10e8529471 add node pruning log line 2020-05-28 21:34:01 -04:00
James Bardin 75ec201e6a temporarily disable module depends_on test 2020-05-28 21:33:56 -04:00
James Bardin d97a210ad3 don't connect destroyers to module expanders
Resource destroy nodes can only depend on other resources. Connecting
them to their module expander can introduce cycles when the module
expander depends on resources in the destroyer's subgraph.
2020-05-28 21:33:08 -04:00
James Bardin a9e0f46f23 expanded module depends_on test 2020-05-28 21:33:05 -04:00
James Bardin 70ac00595b fix apply tests
sSme apply tests had outputs in empty modules, which won't be saved to
state.
2020-05-28 21:30:44 -04:00
James Bardin 48757bcbe0 get rid of the NodeOutputOrphan
We don't need another node type for orphaned outptus, they are just
outputs being removed for a different reason than destroy. Use the
NodeDestroyableOutput implementation.

Destroy outputs also don't need to be referencers, since they are being
removed.

Rename DestroyOutputTransformer to destroyRootOutputTransformer, and add
an explanation as to why it is the only transformer that requires an
exception to know when it's involved from the destroy command.
2020-05-28 21:30:44 -04:00
James Bardin dc1b133831 remove requiresInstanceExpansion
simplification allows us to settle on a single interface,
graphNodeExpandsInstances for all types if instance expanders. The only
other specific class of resource we need to detect during pruning is the
nodeExpandApplyableResource node, which is already classified under the
GraphNodeResourceInstance interface.
2020-05-28 21:30:44 -04:00
James Bardin 082f91cd85 fix ModulePath for nodeExpandModule
ModulePath was incorrectly returning the parent module, because it did
not implement ReferenceOutside. With ReferenceOutside working correctly,
we can have ModulePath return the real path and remove the special case
for this during pruning.
2020-05-28 21:30:44 -04:00
James Bardin c638252210 pruneUnusedNodesTransformer
Create a single transformer to remove all unused nodes from the apply
graph. This is similar to the combination of the resource pruning done
in the destroy edge transformer, and the unused values transformer. In
addition to resources, variables, locals, and outputs, we now need to
remove unused module expansion nodes as well. Since these can all be
interdependent, we need to process them as whole in a single
transformation.
2020-05-28 21:30:42 -04:00
James Bardin 7122b271f9 restore the ordering of nested modules
In order for depends_on to work, modules need to implicitly depend on
their child modules. This will have little effect on terraform's
concurrency, as configuration trees are always much wider than they are
deep.
2020-05-28 21:30:12 -04:00
James Bardin 63b54f2b72 remove unused transformer 2020-05-28 21:30:12 -04:00
James Bardin 5c401bead9 nodeCloseModule needs GraphNodeReferenceOutside
The ModulePath method was incorrect, and standing in for
GraphNodeReferenceOutside. Add ReferenceOutside so we can fix
ModulePath.
2020-05-28 21:30:12 -04:00
James Bardin 009a136fa2 requiresInstanceExpansion and instanceExpander
create interfaces that nodes can implement to declare whether they
expand into instances of some sort, using the instances.Expander, and/or
whether use the instances.Expander to find instances.

included is a rough transformer implementation to remove these nodes
from the apply graph.
2020-05-28 21:30:12 -04:00
James Bardin 741aab31d1 delete unused code
this search for orphans was never used
2020-05-28 21:30:12 -04:00
James Bardin 8ba63110ec
Merge pull request #25005 from hashicorp/jbardin/module-depends-on
Module depends_on
2020-05-28 21:29:04 -04:00
Martin Atkins b0839175b1
Update CHANGELOG.md 2020-05-28 16:19:02 -07:00
Martin Atkins ec7dce0974
Update CHANGELOG.md 2020-05-28 16:13:23 -07:00
Martin Atkins d1bc412220 configs: Custom variable validation is no longer experimental
All of the feedback from the experiment described enhancements that can
potentially be added later without breaking changes, so this change simply
removes the experiment gate from the feature as originally implemented
with no changes to its functionality.

Further enhancements may follow in later releases, but the goal of this
change is just to ship the feature exactly as it was under the experiment.

Most of the changes here are cleaning up the experiment opt-ins from our
test cases. The most important parts are in configs/experiments.go and in
experiments/experiment.go .
2020-05-28 16:07:59 -07:00
Alisdair McDiarmid 8b279b6f34 plugin/discovery: Remove dead code
Provider installation is now handled in the internal/getproviders
package instead.
2020-05-28 15:20:41 -04:00
Alisdair McDiarmid ca40107066 command/init: Better diagnostics for provider 404s
Fetching a default namespace provider from the public registry can
result in 404 Not Found error. This might be caused by a previously-
default provider moving to a new namespace, which means that the
configuration needs to be upgraded to use an explicit provider source.

This commit adds a more detailed diagnostic for this situation,
suggesting that the intended provider might be in a new namespace. The
recommended course of action is to run the 0.13upgrade command to
generate the correct required_providers configuration.
2020-05-28 09:24:32 -04:00
Alisdair McDiarmid 01f91316da
Update CHANGELOG.md 2020-05-28 09:11:55 -04:00
Alisdair McDiarmid ef28671b34
Merge pull request #24932 from hashicorp/signing-language
Modify language for reporting signing state
2020-05-28 09:09:34 -04:00
Daniel Dreier 2ff875cabe
Merge pull request #25030 from gkramer/patch-1
Update modules.html.md
2020-05-27 16:37:08 -07:00
Pam Selle a6634d2d6c
Add module count and for_each to 0.13 changelog 2020-05-27 16:44:43 -04:00
James Bardin d2466fab3d add module self-reference test 2020-05-27 15:09:52 -04:00
Paddy 5127f1ef8b
command: Unmanaged providers
This adds supports for "unmanaged" providers, or providers with process
lifecycles not controlled by Terraform. These providers are assumed to
be started before Terraform is launched, and are assumed to shut
themselves down after Terraform has finished running.

To do this, we must update the go-plugin dependency to v1.3.0, which
added support for the "test mode" plugin serving that powers all this.

As a side-effect of not needing to manage the process lifecycle anymore,
Terraform also no longer needs to worry about the provider's binary, as
it won't be used for anything anymore. Because of this, we can disable
the init behavior that concerns itself with downloading that provider's
binary, checking its version, and otherwise managing the binary.

This is all managed on a per-provider basis, so managed providers that
Terraform downloads, starts, and stops can be used in the same commands
as unmanaged providers. The TF_REATTACH_PROVIDERS environment variable
is added, and is a JSON encoding of the provider's address to the
information we need to connect to it.

This change enables two benefits: first, delve and other debuggers can
now be attached to provider server processes, and Terraform can connect.
This allows for attaching debuggers to provider processes, which before
was difficult to impossible. Second, it allows the SDK test framework to
host the provider in the same process as the test driver, while running
a production Terraform binary against the provider. This allows for Go's
built-in race detector and test coverage tooling to work as expected in
provider tests.

Unmanaged providers are expected to work in the exact same way as
managed providers, with one caveat: Terraform kills provider processes
and restarts them once per graph walk, meaning multiple times during
most Terraform CLI commands. As unmanaged providers can't be killed by
Terraform, and have no visibility into graph walks, unmanaged providers
are likely to have differences in how their global mutable state behaves
when compared to managed providers. Namely, unmanaged providers are
likely to retain global state when managed providers would have reset
it. Developers relying on global state should be aware of this.
2020-05-26 17:48:57 -07:00
Alisdair McDiarmid 5d0b75df7a
Merge pull request #25013 from hashicorp/alisdair/ui-data-source-read
command: Add UI hooks for read actions
2020-05-26 15:59:30 -04:00
Alisdair McDiarmid c9fcdbc579
Merge pull request #25034 from hashicorp/alisdair/terraform-init-provider-source-bug
command/init: Use full config for determining provider requirements
2020-05-26 15:59:02 -04:00
Paul Tyng 22ef5cc99c Modify language for reporting signing state
Be more explicit about the signing status of fetched plugins and provide documentation about the different signing options.
2020-05-26 13:14:05 -04:00
Alisdair McDiarmid 62d826e066 command/init: Use full config for provider reqs
Relying on the early config for provider requirements was necessary in
Terraform 0.12, to allow the 0.12upgrade command to run after init
installs providers.

However in 0.13, the same restrictions do not apply, and the detection
of provider requirements has changed. As a result, the early config
loader gives incorrect provider requirements in some circumstances,
such as those in the new test in this commit.

Therefore we are changing the init command to use the requirements found
by the full configuration loader. This also means that we can remove the
internal initwd CheckCoreVersionRequirements function.
2020-05-25 16:50:12 -04:00
Garron Kramer f3db1232a0
Update modules.html.md
the -module option is no longer present.
2020-05-25 15:41:45 +03:00
Daniel Dreier df39e0a806
Merge pull request #23989 from tatsuo48/fix_sample_code
fix sample code
2020-05-21 15:03:52 -07:00
Daniel Dreier 398972aa24
Merge pull request #22826 from yessarath/patch-1
local backend example added
2020-05-21 14:54:55 -07:00
Daniel Dreier f737d684e5
Update website/docs/providers/terraform/d/remote_state.html.md
Co-authored-by: Nick Fagerlund <nick@hashicorp.com>
2020-05-21 14:54:40 -07:00
Daniel Dreier d006b85c26
Update website/docs/providers/terraform/d/remote_state.html.md
Co-authored-by: Nick Fagerlund <nick@hashicorp.com>
2020-05-21 14:54:30 -07:00
Daniel Dreier 1c024aa06f
Merge pull request #24319 from ritarock/improve_doc
improve s3.html.md
2020-05-21 14:33:14 -07:00