Commit Graph

1626 Commits

Author SHA1 Message Date
Mitchell Hashimoto 4cdaf6f687
terraform: ResourceTransformer to ResourceTransformerOld 2016-11-08 13:59:26 -08:00
Mitchell Hashimoto d7aa59be3c
terraform: begin NodePlannableResource 2016-11-08 13:59:26 -08:00
Mitchell Hashimoto dbac0785bc
terraform: tests for the plan graph builder 2016-11-08 13:59:26 -08:00
Mitchell Hashimoto 7557e6e70a
terraform: ConfigTransformer 2016-11-08 13:59:25 -08:00
Mitchell Hashimoto 4f0d68dda4
terraform: PlanGraphBuilder 2016-11-08 13:59:17 -08:00
Mitchell Hashimoto ce4ff06d25
terraform: prepare Plan for shadowing 2016-11-08 13:28:50 -08:00
Mitchell Hashimoto f9fee4106f
terraform: Diff.Prune 2016-11-08 13:28:50 -08:00
Mitchell Hashimoto 9890a2ee91
terraform: prune orphan outputs in old graph
This makes the old graph also prune orphan outputs in modules.
This will fix shadow graph errors such as #9905 since the old graph will
also behave correctly in these scenarios.

Luckily, because orphan outputs don't rely on anything, we were able to
simply use the same transformer!
2016-11-08 13:24:09 -08:00
Mitchell Hashimoto fb29b6a2dc
terraform: destroy edges should never point to self
Fixes #9920

This was an issue caught with the shadow graph. Self references in
provisioners were causing a self-edge on destroy apply graphs.

We need to explicitly check that we're not creating an edge to ourself.
This is also how the reference transformer works.
2016-11-08 12:27:33 -08:00
Mitchell Hashimoto f580a8ed7b Merge pull request #9894 from hashicorp/b-provider-alias
terraform: configure provider aliases in the new apply graph
2016-11-07 07:59:33 -08:00
Mitchell Hashimoto 1beda4cd07 Merge pull request #9898 from hashicorp/b-new-ref-existing
terraform: remove pruning of module vars if they ref non-existing nodes
2016-11-07 07:59:25 -08:00
Mitchell Hashimoto a5df3973a4
terraform: module variables should be pruned if nothing depends on them 2016-11-04 18:58:03 -07:00
Mitchell Hashimoto b488e51f56
terraform: tests for ReferenceMap.References 2016-11-04 18:40:09 -07:00
Mitchell Hashimoto b7954a42fe
terraform: remove pruning of module vars if they ref non-existing nodes
Fixes a shadow graph error found during usage.

The new apply graph was only adding module variables that referenced
data that existed _in the graph_. This isn't a valid optimization since
the data it is referencing may be in the state with no diff, and
therefore available but not in the graph.

This just removes that optimization logic, which causes no failing
tests. It also adds a test that exposes the bug if we had the pruning
logic.
2016-11-04 17:47:20 -07:00
Mitchell Hashimoto d7ed6637c1
terraform: configure provider aliases in the new apply graph
Found via a shadow graph failure:

Provider aliases weren't being configured by the new apply graph.

This was caused by the transform that attaches configs to provider nodes
not being able to handle aliases and therefore not attaching a config.
Added a test to this and fixed it.
2016-11-04 16:51:52 -07:00
Mitchell Hashimoto 944ffdb95b
terraform: multi-var ordering is by count
Fixes #9444

This appears to be a regression from 0.7.0, but there were no tests
covering it so we missed it and changed the behavior at some point! Oh
no.

This PR make the ordering of multi-var access: `resource.name.*.attr`
consistent: it is the ordering of the count, not the lexical ordering of
the value. This allows behavior where two lists are indexed by count
index and can be assumed to be related (for example user data for an aws
instance, as shown in the above referenced issue).

Two new context tests added to cover this case.
2016-11-04 11:07:01 -07:00
Mitchell Hashimoto 38314186f1
release: cleanup after v0.7.9 2016-11-04 09:39:49 -07:00
Mitchell Hashimoto b313e55fe7
v0.7.9 2016-11-04 16:31:49 +00:00
Mitchell Hashimoto 57c0cadc79 Merge pull request #9666 from hashicorp/jbardin/debug
preliminary debug output
2016-11-04 09:03:58 -07:00
James Bardin 60873827da re-add "Graph after..." logs 2016-11-04 12:03:16 -04:00
Mitchell Hashimoto f6dacab0ba Merge pull request #9794 from hashicorp/b-partial-input
command/meta: always ask for unset variable input
2016-11-04 08:48:05 -07:00
James Bardin 1cea51a9fa Record walk order in the debug graph
Insert the walk order into the graph labels. Removed some extra debug
output.
2016-11-04 11:39:46 -04:00
James Bardin 354f04f104 Add some basic tests
Also make DebugHook noop when there is no debuginfo set
2016-11-04 11:39:46 -04:00
James Bardin 797a1b339d DebugInfo and DebugGraph
Implement debugInfo and the DebugGraph

DebugInfo will be a global variable through which graph debug
information can we written to a compressed archive. The DebugInfo
methods are all safe for concurrent use, and noop with a nil receiver.
The API outside of the terraform package will be to call SetDebugInfo
to create the archive, and CloseDebugInfo() to properly close the file.
Each write to the archive will be flushed and sync'ed individually, so
in the event of a crash or a missing call to Close, the archive can
still be recovered.

The DebugGraph is a representation of a terraform Graph to be written to
the debug archive, currently in dot format. The DebugGraph also contains
an internal buffer with Printf and Write methods to add to this buffer.
The buffer will be written to an accompanying file in the debug archive
along with the graph.

This also adds a GraphNodeDebugger interface. Any node implementing
`NodeDebug() string` can output information to annotate the debug graph
node, and add the data to the log. This interface may change or be
removed to provide richer options for debugging graph nodes.

The new graph builders all delegate the build to the BasicGraphBuilder.
Having a Name field lets us differentiate the actual builder
implementation in the debug graphs.
2016-11-04 11:30:51 -04:00
James Bardin 07ec946e7e Merge pull request #9853 from hashicorp/jbardin/cbd-datasource
fix CreateBeforeDestroy with datasources
2016-11-04 09:44:42 -04:00
James Bardin 40886218d5 Add test fixture for new CBD ancestor fix
This test will fail with a cycle before we check ancestors for
CreateBeforeDestroy.
2016-11-03 18:31:25 -04:00
James Bardin cf3a259cd9 fix CreateBeforeDestroy with datasources
The graph transformation we implement around create_before_destroy
need to re-order all resources that depend on the create_before_destroy
resource. Up until now, we've requires that users mark all of these
resources as create_before_destroy. Data soruces however don't have a
lifecycle block for create_before_destroy, and could not be marked this
way.

This PR checks each DestroyNode that doesn't implement CreateBeforeDestroy
for any ancestors that do implement CreateBeforeDestroy. If there are
any, we inherit the behavior and re-order the graph as such.
2016-11-03 17:08:24 -04:00
Mitchell Hashimoto 90bfff3026
terraform: shadow graph uses GraphWalkerPanicwrap to catch errors 2016-11-03 12:09:51 -07:00
Mitchell Hashimoto da508d6a8b
terraform: GraphWalkerPanicwrap catches panics during graph walks 2016-11-03 12:08:55 -07:00
Mitchell Hashimoto d2e9c35007
terraform: new apply graph creates provisioners in modules
Fixes #9840

The new apply graph wasn't properly nesting provisioners. This resulted
in reading the provisioners being nil on apply in the shadow graph which
caused the crash in the above issue.

The actual cause of this is that the new graphs we're moving towards do
not have any "flattening" (they are flat to begin with): all modules are
in the root graph from the beginning of construction versus building a
number of different graphs and flattening them. The transform that adds
the provisioners wasn't modified to handle already-flat graphs and so
was only adding provisioners to the root module, not children.

The change modifies the `MissingProvisionerTransformer` (primarily) to
support already-flat graphs and add provisioners for all module levels.
Tests are there to cover this as well.

**NOTE:** This PR focuses on fixing that specific issue. I'm going to follow up
this PR with another PR that is more focused on being robust against
crashing (more nil checks, recover() for shadow graph, etc.). In the
interest of focus and keeping a PR reviewable this focuses only on the
issue itself.
2016-11-03 10:25:11 -07:00
Mitchell Hashimoto 9e5d1f10b0
terraform: add test to verify orphan outputs in modules are removed
For #7598

This doesn't work with the old graph, we guard it as such.
2016-11-01 22:42:41 -07:00
Mitchell Hashimoto 1248b147ac
command/meta: always ask for unset variable input
Fixes #7975

This changes the InputMode for the CLI to always be:

    InputModeProvider | InputModeVar | InputModeVarUnset

Which means:

  * Ask for provider variables
  * Ask for user variables _that are not already set_

The change is the latter point. Before, we'd only ask for variables if
zero were given. This forces the user to either have no variables set
via the CLI, env vars, tfvars or ALL variables, but no in between. As
reported in #7975, this isn't expected behavior.

The new change makes is so that unset variables are always asked for.
Users can retain the previous behavior by setting `-input=false`. This
would ensure that variables set by external sources cover all cases.
2016-11-01 19:16:43 -07:00
clint 744d1648f6 release: cleanup after v0.7.8 2016-11-01 19:06:14 +00:00
clint f61ff7d005
v0.7.8 2016-11-01 18:45:37 +00:00
Mitchell Hashimoto df981b234d
terraform: NewComputed doesn't quit Same logic
For #9618, we added the ability to ignore old diffs that were computed
and removed (because the ultimate value ended up being the same). This
ended up breaking computed list/set logic.

The correct behavior, as is evident by how the other "skip" logics work,
is to set `ok = true` so that the remainder of the logic can run which
handles stuff such as computed lists and sets.
2016-11-01 09:53:53 -07:00
Mitchell Hashimoto 86edaeda60 Merge pull request #9707 from hashicorp/b-prevent-destroy-count
terraform: prevent_destroy works for decreasing count
2016-10-31 13:24:16 -07:00
Mitchell Hashimoto 144f31b6f2 Merge pull request #9728 from hashicorp/b-prov-cycle
terraform: validate graph on resource expansation to catch cycles
2016-10-31 13:24:10 -07:00
Mitchell Hashimoto 92abaf1905 Merge pull request #9731 from hashicorp/b-deposed-hook
terraform: deposed should trigger PostApply hook
2016-10-31 13:23:47 -07:00
Mitchell Hashimoto 50d493163d
terraform: fall through on type conversion failure
This fixes a test but also loosens the requirements of Variables() so
that the Validate() call on Terraform can actually catch those errors.
2016-10-31 11:31:01 -07:00
Mitchell Hashimoto bac66430cb
terraform: consistent variable values for booleans
Fixes #6447

This ensures that all variables of type string are consistently
converted to a string value upon running Terraform.

The place this is done is in the `Variables()` call within the
`terraform` package. This is the function responsible for loading and
merging the variables from the various sources and seems ideal for
proper conversion to consistent values for various types. We actually
already had tests to this effect.

This also adds docs that talk about the fake-ish boolean variables
Terraform currently has and about how in future versions we'll likely
support them properly, which can cause BC issues so beware.
2016-10-31 11:22:26 -07:00
Mitchell Hashimoto c21610f533
terraform: for tempEnv, if the var wans't set before, unset
This was causing flaky behavior in our tests because `TF_VAR_x=""` is
actually a valid env var. For tests, we need to actually unset env vars
that haven't been set before.
2016-10-31 11:01:05 -07:00
Mitchell Hashimoto b005a83143
terraform: deposed should trigger PostApply hook
Fixes #6327

Deposed instances weren't calling PostApply which was causing the counts
for what happened during `apply` to be wrong. This was a simple fix to
ensure we call that hook.
2016-10-30 15:24:20 -07:00
Mitchell Hashimoto 1aed6f8abb
terraform: validate graph on resource expansation to catch cycles
Fixes #5342

The dynamically expanded subgraph wasn't being validated so cycles
weren't being caught here and Terraform would just hang. This fixes
that.

Note that it may make sense to validate higher level when the graph is
expanded but there are certain cases we actually expect the graph to
potentially be invalid, so this seems safer for now.
2016-10-30 14:27:08 -07:00
Mitchell Hashimoto a332c121bc
terraform: prevent_destroy works for decreasing count
Fixes #5826

The `prevent_destroy` lifecycle configuration was not being checked when
the count was decreased for a resource with a count. It was only
checking when attributes changed on pre-existing resources.

This fixes that.
2016-10-28 21:31:47 -04:00
Mitchell Hashimoto 3fd390b699
terraform: disallow simple variables ("foo")
Fixes #5338 (and I'm sure many others)

There is no use case for "simple" variables in Terraform at all so
anytime one is found it should be an error.

There is a _huge_ backwards incompatibility here that was not supposed
to be by design but I'm sure a lot of people are relying on: in the
`template_file` datasource, this bug allowed you to not escape your
interpolations and have the work. For example:

```
data "template_file" "foo" {
  template = "${a}"
  vars { a = 12 }
}
```

The above would work, but it shouldn't. The template should have to be
`"$${a}"` (to escape the interpolation).

Because of this BC, I recommend holding this until Terraform 0.8.0 and
documenting it carefully. As part of this PR, I've added some special
error message notes.
2016-10-28 15:27:11 -04:00
Mitchell Hashimoto 3f36787207 Merge pull request #9618 from hashicorp/b-computed-prim
helper/schema,terraform: handle computed primitives in diffs
2016-10-28 10:44:13 -04:00
Mitchell Hashimoto 69b32223b8 Merge pull request #9633 from hashicorp/f-experiment
helper/experiment: a helper for setting, making experiments
2016-10-27 11:22:07 -04:00
Mitchell Hashimoto f142978456
terraform: add test to verify tainted resources don't process
ignore_changes

For #7855
2016-10-27 08:44:59 -04:00
Mitchell Hashimoto 984cade39f
Merge branch 'fix-taint-w-ignorechanges' of https://github.com/sl1pm4t/terraform into sl1pm4t-fix-taint-w-ignorechanges 2016-10-27 08:32:37 -04:00
Mitchell Hashimoto af82be19ea
helper/experiment: a helper for setting, making experiments
This creates a standard package and interface for defining, querying,
setting experiments (`-X` flags).

I expect we'll want to continue to introduce various features behind
experimental flags. I want to make doing this as easy as possible and I
want to make _removing_ experiments as easy as possible as well.

The goal with this packge has been to rely on the compiler enforcing our
experiment references as much as possible. This means that every
experiment is a global variable that must be referenced directly, so
when it is removed you'll get compiler errors where the experiment is
referenced.

This also unifies and makes it easy to grab CLI flags to enable/disable
experiments as well as env vars! This way defining an experiment is just
a couple lines of code (documented on the package).
2016-10-26 15:47:58 -04:00
Mitchell Hashimoto aed23a0a31 Merge pull request #9527 from hashicorp/f-destroy-builder2
terraform: destroy graph builder based on state
2016-10-26 12:53:20 -04:00
Mitchell Hashimoto 95d37ea79c
helper/schema,terraform: handle computed primtives in diffs
Fixes #3309

There are two primary changes, one to how helper/schema creates diffs
and one to how Terraform compares diffs. Both require careful
understanding.

== 1. helper/schema Changes

helper/schema, given any primitive field (string, int, bool, etc.)
_used to_ create a basic diff when given a computed new value (i.e. from
an unkown interpolation). This would put in the plan that the old value
is whatever the old value was, and the new value was the actual
interpolation. For example, from #3309, the diff showed the following:

```
~ module.test.aws_eip.test-instance.0
    instance: "<INSTANCE ID>" => "${element(aws_instance.test-instance.*.id, count.index)}"
```

Then, when running `apply`, the diff would be realized and you would get
a diff mismatch error because it would realize the final value is the
same and remove it from the diff.

**The change:** `helper/schema` now marks unknown primitive values with
`NewComputed` set to true. Semantically this is correct for the diff to
have this information.

== 2. Terraform Diff.Same Changes

Next, the way Terraform compares diffs needed to be updated

Specifically, the case where the diff from the plan had a NewComputed
primitive and the diff from the apply _no longer has that value_. This
is possible if the computed value ended up being the same as the old
value. This is allowed to pass through.

Together, these fix #3309.
2016-10-25 22:36:59 -04:00
Mitchell Hashimoto 4582c2c016
terraform: Stop API added to ResourceProvider 2016-10-25 12:09:44 -07:00
Mitchell Hashimoto a61b7227f5
terraform: Context.Stop() calls Stop on providers if running 2016-10-25 12:08:35 -07:00
Mitchell Hashimoto d338a1ef88
terraform: implement Stop in the mock and shadow 2016-10-25 12:08:35 -07:00
Mitchell Hashimoto 60140b28f4
Revert "Merge pull request #9536 from hashicorp/f-provider-stop"
This reverts commit c3a4cff133, reversing
changes made to 791a02e6e4.

This change requires plugin recompilation and we should hold off until a
minor release for that.
2016-10-25 12:00:36 -07:00
Mitchell Hashimoto 0cca4fc093
terraform: Context.Stop() calls Stop on providers if running 2016-10-25 11:31:55 -07:00
Mitchell Hashimoto 7e2582c47b
terraform: implement Stop in the mock and shadow 2016-10-25 11:31:55 -07:00
Mitchell Hashimoto 2be72cfe03
terraform: Stop API added to ResourceProvider 2016-10-25 11:31:55 -07:00
Mitchell Hashimoto 791a02e6e4
terraform: test that depends_on is used for destroy ordering 2016-10-25 11:05:48 -07:00
Mitchell Hashimoto eb20db92cf
terraform: test that data sources can reference other data sources 2016-10-23 18:53:00 -07:00
Mitchell Hashimoto 1486da91ab
Missed a spot where panic: could still happen 2016-10-23 14:29:15 -07:00
Mitchell Hashimoto 0c3161083c
update CHANGELOG 2016-10-23 14:28:08 -07:00
Mitchell Hashimoto 83b1c82e93
terraform: put quotes before vertex name to avoid false panicwrap
Fixes #9395
2016-10-23 14:23:36 -07:00
Mitchell Hashimoto 5a8ec482a2
terraform: unify destroy/apply graph builders
They're so similar we unify them, they only change in a select few
places. This is very similar to the old graph but is still much simpler.
2016-10-22 12:12:30 -07:00
Mitchell Hashimoto 1523504645
terraform: enable shadow graph and destroy resource mode with addr
This enables the shadow graph since all tests pass!

We also change the destroy node to check the resource type using the
addr since that is always available and reliable. The configuration can
be nil for orphans.
2016-10-22 12:12:30 -07:00
Mitchell Hashimoto a4aea3e085
terraform: destroy apply graph builder should disable providers 2016-10-22 12:12:30 -07:00
Mitchell Hashimoto db6d87b16c
terraform: destroy node should understand data sources
This makes the new destroy nodes undestand data sourcs and call the
correct apply function.
2016-10-22 12:12:30 -07:00
Mitchell Hashimoto ac9a049d19
terraform: Diff.Equal ignores ModuleDiff.Destroy
This is necessary to get the shadow working properly with the destroy
graph since the destroy graph doesn't set this field but the end state
is still the same.
2016-10-22 12:12:30 -07:00
Mitchell Hashimoto ceb613d449
terraform: don't set destroy module on diff
This is something that should be determined and done during an apply. It
doesn't make a lot of sense that the plan is doing it (in its current
form at least).
2016-10-22 12:12:30 -07:00
Mitchell Hashimoto ab4ebcc5c7
terraform: TargetsTransformer on destroy plan
This enables targeting to work properly on planning destroys
2016-10-22 12:12:30 -07:00
Mitchell Hashimoto 2d4f65cc94
terraform: disable shadowing destroy graph for now
It doesn't fully work so we want to wait until we think its ready before
we start the shadowing.
2016-10-22 12:12:29 -07:00
Mitchell Hashimoto 480a414c40
terraform: destroy module nodes show up in plan destroy 2016-10-22 12:12:29 -07:00
Mitchell Hashimoto e68327e765
terraform: add config transformer to enable preventDestroy 2016-10-22 12:12:29 -07:00
Mitchell Hashimoto 0ed896a313
terraform: implement destroy planning basics from state 2016-10-22 12:12:29 -07:00
Mitchell Hashimoto db807f4b0f
terraform: destroy graph builder, -Xnew-destroy flag 2016-10-22 12:12:29 -07:00
Mitchell Hashimoto 3dd64d9f2e
terraform: ResourceConfig.Equal should sort ComputedKeys
This was causing otherwise equal ResourceConfigs to report non-equal
which was incorrect, thus causing incorrect shadow graph errors.
2016-10-22 12:00:05 -07:00
Mitchell Hashimoto f8e35ecb2f
terraform: log starting graph walk outside of the goroutine
This is so ordering makes a bit more sense reliably.
2016-10-21 16:20:38 -07:00
Mitchell Hashimoto ae4f79e3b6
command/meta: add -shadow flag to disable shadow graph
Since it is still very much possible for this to cause problems, this
can be used to disable the shadow graph. We'll purposely not document
this since the goal is to remove this flag as we become more confident
with it.
2016-10-21 14:25:05 -07:00
Mitchell Hashimoto 4a6cc3b100
terraform: new apply resource node supports data sources
This enables the new apply graph's resource node to apply data sources.
Data sources appear to only be tested for "refresh" which is likely
where they're set but they've also been implemented (not my code, not
trying to edit code) within the "apply" operation as well.

This adds an apply test to ensure data sources work, and then modifies
the new apply node to support data sources.
2016-10-20 22:03:48 -07:00
Mitchell Hashimoto 1d27e554a5
terraform: test to ensure data sources work on Apply operation
It appears data sources have always been coded to work during apply, as
can be verified with this test (no impl. changes were necessary to make
it pass).

This test should be added to ensure our apply graph always works with
data sources as well.
2016-10-20 21:53:54 -07:00
Mitchell Hashimoto 2c1a21a8ef
terraform: disable shadowing the experimental graph 2016-10-20 15:17:28 -07:00
Mitchell Hashimoto a89dcfd1b1
terraform: re-enable shadow tests 2016-10-19 15:09:01 -07:00
Mitchell Hashimoto 51e90cd641
terraform: move references for disable provider transform to old 2016-10-19 15:07:00 -07:00
Mitchell Hashimoto fa25a3051b
terraform: orphan resources in old graph need unique ID 2016-10-19 15:05:38 -07:00
Mitchell Hashimoto d27c8fbbbc
terraform: compared states from shadow graph must be pruned 2016-10-19 15:01:54 -07:00
Mitchell Hashimoto e4ef1fe553
terraform: disable providers in new apply graph
This adds the proper logic for "disabling" providers to the new apply
graph: interolating and storing the config for inheritance but not
actually initializing and configuring the provider.

This is important since parent modules will often contain incomplete
provider configurations for the purpose of inheritance that would error
if they were actually attempted to be configured (since they're
incomplete). If the provider is not used, it should be "disabled".
2016-10-19 14:54:00 -07:00
Mitchell Hashimoto 13b9007474
terraform: logic for shadowing the original graph
This introduces failing tests. How many is unknown since shadow graph
errors cause a panic.
2016-10-19 14:17:12 -07:00
Mitchell Hashimoto 7d36e991da
terraform: resource address internal can parse data resource addrs 2016-10-19 14:12:30 -07:00
Mitchell Hashimoto 5d598ad217
terraform: if components is closed, initialize closed components
This was happening if the shadow initializes a provider that is never
used by the real side. We need to make sure it starts closed.
2016-10-19 14:10:46 -07:00
Mitchell Hashimoto d87bdc2d2b
terraform: update destroy resource with proper unique-ifier for shadow
This adds a proper unique extra field so that the shadow graph can
properly compare values.
2016-10-19 13:51:11 -07:00
Mitchell Hashimoto c9c1912b34
terraform: missing fields from ApplyGraphBuilder after master rebase 2016-10-19 13:46:32 -07:00
Mitchell Hashimoto e59efa024b
terraform: fix merge issues with master 2016-10-19 13:41:30 -07:00
Mitchell Hashimoto ec15783f24
-Xnew-apply to enable the new apply graph 2016-10-19 13:39:28 -07:00
Mitchell Hashimoto eb9ecea863
terraform: don't set Provider on destroy nodes
This doesn't explicitly set `rs.Provider` on destroy nodes.

To be honest, I'm not sure why this was done in the first place (git
blame points to 6fda7bb5483a155b8ae1e1e4e4b7b7c4073bc1d9). Tests always
passed without it, and by adding it it causes other tests to fail. I
should've never changed those other tests.

Removing it now to get tests passing, this also reverts the test changes
made in 8213824962f085279810f04b60b95d1176a3a3f2.
2016-10-19 13:39:13 -07:00
Mitchell Hashimoto 7c2c9b82a3
terraform: interpolation for multi-var checks both ".0" and "" suffix 2016-10-19 13:39:13 -07:00
Mitchell Hashimoto 9ac4ee4b52
terraform: transform module variables does parent first 2016-10-19 13:38:53 -07:00
Mitchell Hashimoto 924f7a49e0
terraform: module variable transform must do children later (tested) 2016-10-19 13:38:53 -07:00
Mitchell Hashimoto c1664d2eaa
terraform: cbd works! 2016-10-19 13:38:53 -07:00
Mitchell Hashimoto 23665790f3
terraform: destroy resource should have no references 2016-10-19 13:38:53 -07:00
Mitchell Hashimoto aaee4df363
terraform: working on enabling CBD, some cycles 2016-10-19 13:38:53 -07:00
Mitchell Hashimoto 4aa84a2071
terraform: CBD makes the proper edge connections for dependent resources 2016-10-19 13:38:53 -07:00
Mitchell Hashimoto 3d4937b784
terraform: FlatConfigTransformer 2016-10-19 13:38:53 -07:00
Mitchell Hashimoto 6622ca001d
terraform: abstract resource nodes 2016-10-19 13:38:53 -07:00
Mitchell Hashimoto 046faf247a
terraform: cleanup and failing test for CBD 2016-10-19 13:38:53 -07:00
Mitchell Hashimoto 4e8e6cd661
dag: add EdgesFrom, EdgesTo, needs tests 2016-10-19 13:38:53 -07:00
Mitchell Hashimoto b9b23e8483
terraform: improved logging 2016-10-19 13:38:53 -07:00
Mitchell Hashimoto 7baf64f806
terraform: starting CBD, destroy edge for the destroy relationship 2016-10-19 13:38:52 -07:00
Mitchell Hashimoto 4988378ccb
terraform: remove diff transformer test that no longer happens 2016-10-19 13:38:52 -07:00
Mitchell Hashimoto 311d27108e
terraform: Enable DestroyEdgeTransformer 2016-10-19 13:38:52 -07:00
Mitchell Hashimoto 08dade5475
terraform: more destroy edge tests 2016-10-19 13:38:52 -07:00
Mitchell Hashimoto 7b2bd93094
terraform: test the destroy edge transform 2016-10-19 13:38:52 -07:00
Mitchell Hashimoto bd5d97f9f5
terraform: transform to attach resource configs 2016-10-19 13:38:52 -07:00
Mitchell Hashimoto ceb5c53d56
terraform: destroy nodes should call post state update hook 2016-10-19 13:38:52 -07:00
Mitchell Hashimoto 56b4521d8f
terraform: provider depends on config references 2016-10-19 13:38:52 -07:00
Mitchell Hashimoto ebc7d209a7
terraform: new graph fixes ".0" and "" boundaries on counts 2016-10-19 13:38:52 -07:00
Mitchell Hashimoto 2e8cb94a5e
terraform: orphan outputs are deleted from the state 2016-10-19 13:38:52 -07:00
Mitchell Hashimoto 38b9f7794d
terraform: reference transformer shouldn't make loop to self 2016-10-19 13:38:52 -07:00
Mitchell Hashimoto 5018617049
terraform: change node name so that it shows up properly 2016-10-19 13:38:52 -07:00
Mitchell Hashimoto cd04ccfa62
terraform: update a test to be easier to target 2016-10-19 13:38:51 -07:00
Mitchell Hashimoto 80ef7f1acf
terraform: properly compare bad diffs 2016-10-19 13:38:51 -07:00
Mitchell Hashimoto 9e8cd48cda
terraform: add destroy nodes, destroys kind of work 2016-10-19 13:38:51 -07:00
Mitchell Hashimoto 2e8a419fd8
terraform: starting work on destroy 2016-10-19 13:38:51 -07:00
Mitchell Hashimoto dfa02e4412
terraform: rename attach config to only attach provider config 2016-10-19 13:38:51 -07:00
Mitchell Hashimoto 0e666aa575
terraform: get tests to not panic on failures 2016-10-19 13:38:51 -07:00
Mitchell Hashimoto 0463ad74a8
terraform: RootVariableTransform 2016-10-19 13:38:51 -07:00
Mitchell Hashimoto 993c29f34a
terraform: move ModuleVariableTransformer to its own file 2016-10-19 13:38:51 -07:00
Mitchell Hashimoto 0d815872e1
terraform: tests for module variable node 2016-10-19 13:38:51 -07:00
Mitchell Hashimoto 3fb83f013e
terraform: depend on parent items 2016-10-19 13:38:51 -07:00
Mitchell Hashimoto ad03a21040
terraform: rename to ModuleVariable 2016-10-19 13:38:51 -07:00
Mitchell Hashimoto 4dfdc52ba0
terraform: first stap at module variables, going to redo some things 2016-10-19 13:38:51 -07:00
Mitchell Hashimoto 6376c4ca9b
terraform: update comment 2016-10-19 13:38:51 -07:00
Mitchell Hashimoto f2aa880625
terraform: proper prefix for output connects 2016-10-19 13:38:50 -07:00
Mitchell Hashimoto 7d07f20893
terraform: fix references to module outputs 2016-10-19 13:38:50 -07:00
Mitchell Hashimoto 0d7674b079
terraform: apply builder adds outputs to graphs 2016-10-19 13:38:50 -07:00
Mitchell Hashimoto ba51295267
terraform: ReferenceTransform test 2016-10-19 13:38:50 -07:00
Mitchell Hashimoto 21888b1227
terraform: test for referencetransform for modules 2016-10-19 13:38:50 -07:00
Mitchell Hashimoto 994f5ce773
terraform: ReferenceTransform to connect references 2016-10-19 13:38:50 -07:00
Mitchell Hashimoto e9e8304e95
terraform: new output transform that isn't used yet 2016-10-19 13:38:50 -07:00
Mitchell Hashimoto 7dd4813730
terraform: rename test to be more easily targetable 2016-10-19 13:38:50 -07:00
Mitchell Hashimoto 5220cba77c
terraform: enable provisioners to execute 2016-10-19 13:38:50 -07:00
Mitchell Hashimoto 0f0eecfee7
terraform: add provisioner nodes to the apply graph 2016-10-19 13:38:50 -07:00
Mitchell Hashimoto 4033e90474
terraform: clarify commment 2016-10-19 13:38:50 -07:00
Mitchell Hashimoto 39abec4970
terraform: NodeApplyableProvider evals with config 2016-10-19 13:38:50 -07:00
Mitchell Hashimoto 79a742c1ae
terraform: new provider graph node for flattened world 2016-10-19 13:38:49 -07:00
Mitchell Hashimoto b2ef4e9ac0
terraform: add way to toggle the graphs to use for apply 2016-10-19 13:38:49 -07:00
Mitchell Hashimoto 11578f0792
terraform: tests for ParentProviderTransformer 2016-10-19 13:38:49 -07:00
Mitchell Hashimoto 87bff933ef
terraform: ParentProviderTransform to connect parent providers 2016-10-19 13:38:49 -07:00
Mitchell Hashimoto ba751c4e3b
terraform: comment to avoid panic 2016-10-19 13:38:49 -07:00
Mitchell Hashimoto e784e4a434
terraform: remove more nil panics (doesn't change test logic) 2016-10-19 13:38:49 -07:00
Mitchell Hashimoto 9ea9e52185
terraform: rename Config to Module, tests for diff transform 2016-10-19 13:38:49 -07:00
Mitchell Hashimoto dcc3eb3011
terraform: test for ResourceAddress.stateId() 2016-10-19 13:38:49 -07:00
Mitchell Hashimoto 5828a0a9ac
terraform: minimal applies work! 2016-10-19 13:38:49 -07:00
Mitchell Hashimoto dc9b9eee44
terraform: connect providers in the apply graph 2016-10-19 13:38:49 -07:00
Mitchell Hashimoto 77b9177bd5
terraform: an incredible number of failing tests! 2016-10-19 13:38:49 -07:00
Mitchell Hashimoto 3f090df26e
terraform: start apply-based graph builder, basic diff transform 2016-10-19 13:38:01 -07:00
Mitchell Hashimoto 361bc5a8df
terraform: parse internal resource addresses used in state/diff 2016-10-19 13:38:01 -07:00
Mitchell Hashimoto 50afee2a30
terraform: Diff.Empty should be true for nil Diff 2016-10-19 13:38:01 -07:00
Mitchell Hashimoto 0fe51b334c Merge pull request #9334 from hashicorp/f-shadow-graph
terraform: Shadow Graph
2016-10-19 13:36:10 -07:00
Mitchell Hashimoto 35d1868618
terraform: remove ModuleDiff.GoString
To address comments by @jbardin re: if we had a mutex this will fail
vet.
2016-10-19 10:07:47 -07:00
James Nugent 9e02431ed8 release: clean up after v0.7.7 2016-10-18 13:46:02 +00:00
James Nugent fa6a83ebdc
v0.7.7 2016-10-18 13:36:31 +00:00
Mitchell Hashimoto e2c415a87e
terraform: resource provider must never return pointers to same data
This is a requirement for the parallelism of Terraform to work sanely.
We could deep copy every result but I think this would be unrealistic
and impose a performance cost when it isn't necessary in most cases.
2016-10-17 20:55:20 -07:00
Mitchell Hashimoto 4baed414e7 Merge pull request #9361 from hashicorp/b-interp-multi
terraform: multi-var interpolation should use state for count
2016-10-14 11:13:33 -07:00
clint d9542be43f release: clean up after v0.7.6 2016-10-14 16:43:48 +00:00
clint 754bdda8a7
v0.7.6 2016-10-14 16:32:43 +00:00
James Nugent afe2d7b65b Merge pull request #7320 from dtolnay/conflict
core: Allow refresh of local state with no resources
2016-10-14 11:00:46 -05:00
Mitchell Hashimoto 728a1e5448
terraform: multi-var interpolation should use state for count
Related to #5254

If the count of a resource is interpolated (i.e. `${var.c}`), then it
must be interpolated before any splat variable using that resource can
be used (i.e. `type.name.*.attr`). The original fix for #5254 is to
always ensure that this is the case.

While working on a new apply builder based on the diff in
`f-apply-builder`, this truth no longer always holds. Rather than always
include such a resource, I believe the correct behavior instead is to
use the state as a source of truth during `walkApply` operations.

This change specifically is scoped to `walkApply` operation
interpolations since we know the state of any multi-variable should be
available. The behavior is less clear for other operations so I left the
logic unchanged from prior versions.
2016-10-13 17:57:11 -07:00
James Bardin c5f85f9a91 Merge pull request #9356 from hashicorp/jbardin/TF-9337
Filter nil Deposed values during State init
2016-10-13 16:03:23 -04:00
Clint 46ee2ef51a Merge pull request #6819 from hashicorp/f-aws-vpc-data-sources
provider/aws: data sources for AWS network planning
2016-10-13 14:17:55 -05:00
James Bardin 4f91507d05 Merge pull request #9268 from hashicorp/jbardin/hcl-maps
Get rid of the list when parsing HCL maps for vars
2016-10-13 14:18:29 -04:00
James Bardin 816c04309c Filter nil Deposed values during State init
The Deposed slice wasn't being normalized and nil values could be read
in from a state file. Filter out the nils during init. There is
still a bug in copystructure, but that will be addressed separately.
2016-10-13 13:46:40 -04:00
James Bardin fe4799bd68 Add failing test for nil IsntanceState in State
A nil InstanceState within State/Modules/Resources/Deposed will panic
during a deep copy. The panic needs to be fixed in copystructure, but
the nil probably should have been normalized out before we got here too.
2016-10-13 11:16:03 -04:00
Mitchell Hashimoto baa59ff75d
terraform: fix go vet issues by not using *c to copy 2016-10-12 19:47:21 +08:00
Mitchell Hashimoto 70cee9c1c6
terraform: clean up any final TODOs with comments and placeholders 2016-10-12 19:03:41 +08:00
Mitchell Hashimoto 9a876f65ba
terraform: compare diffs on shadow Apply 2016-10-12 19:01:02 +08:00
Mitchell Hashimoto 7f04b33d3d
terraform: enable shadow walking on Refresh and Validate 2016-10-12 18:57:52 +08:00
Mitchell Hashimoto 98fa7d92a4
terraform: support data source apply for shadows 2016-10-12 18:56:57 +08:00
Mitchell Hashimoto 4c951428d7
terraform: enable shadow on destroy and Plan 2016-10-12 18:50:41 +08:00
Mitchell Hashimoto a9f1166583
terraform: use KeyedValue.Init to avoid initialization race
There were races with ValidateResource in the provider initializing the
data which resulting in lost data for the shadow. A new "Init" function
has been added to the shadow structs to support safe concurrent
initialization.
2016-10-12 18:47:52 +08:00
Mitchell Hashimoto b0801bf125
terraform: ResourceProvider.ReadDataDiff (shadow) 2016-10-11 22:17:31 +08:00
Mitchell Hashimoto 31f8d13678
terraform: Diff.Equal and tests 2016-10-11 22:17:31 +08:00
Mitchell Hashimoto 30596ca371
terraform: sanity test (passes, always passed) 2016-10-11 22:17:31 +08:00
Mitchell Hashimoto c2dd9a7338
terraform: Provier.Diff (shadow) deep copy the config before call 2016-10-11 22:17:31 +08:00
Mitchell Hashimoto 817979c56d
terraform: ResourceProvider.ValidateResource (shadow) config deep copy 2016-10-11 22:17:31 +08:00
Mitchell Hashimoto d7a5cc5b35
terraform: InstanceInfo.uniqueId
This adds a new function to get a unique identifier scoped to the graph
walk in order to identify operations against the same instance. This is
used by the shadow to namespace provider function calls.
2016-10-11 22:17:30 +08:00
Mitchell Hashimoto e2fc0b518f
terraform: ShadowError returns errors, not the close operation 2016-10-11 22:17:30 +08:00
Mitchell Hashimoto d30cfef4d2
terraform: remove shadow eval context since we're not shadowing that
We allow the built in context to work as expected and shadow just the
components now. This is better since it allows us to use much more of
the REAL structures.
2016-10-11 22:17:30 +08:00
Mitchell Hashimoto a014b098b0
terraform: copy the provider input configs for the shadow context 2016-10-11 22:17:30 +08:00
Mitchell Hashimoto fdeb4656c9
terraform: deep copy shadow arguments to avoid state modifications
The arguments passed into Apply, Refresh, Diff could be modified which
caused the shadow comparison later to cause errors. Also, the result
should be deep copied so that it isn't modified.
2016-10-11 22:17:30 +08:00
Mitchell Hashimoto 4de803622d
terraform: ResourceProvisioner shadow 2016-10-11 22:17:30 +08:00
Mitchell Hashimoto 548a585762
terraform: unique ID for destroying resources 2016-10-11 22:17:30 +08:00
Mitchell Hashimoto 5c1af55711
terraform: don't run the shadow graph on interrupt 2016-10-11 22:17:30 +08:00
Mitchell Hashimoto 61c789aace
terraform: shadow graph runs in sequence after the real graph 2016-10-11 22:17:30 +08:00
Mitchell Hashimoto a355d4ad55
terraform: deposed should have a unique ID for instance info 2016-10-11 22:17:30 +08:00
Mitchell Hashimoto 24456c042a
terraform: ResourceProvider (shadow) ValidateResource 2016-10-11 22:17:30 +08:00
Mitchell Hashimoto 3edb8599b1
terraform: Shadow interface, properly string through errors at the right
time
2016-10-11 22:17:29 +08:00
Mitchell Hashimoto 184b4a8b09
terraform: context verifies real and shadow state/diff match 2016-10-11 22:17:29 +08:00
Mitchell Hashimoto 62162427f4
terraform: ResourceProvider (shadow) CloseShadow closes all shadow
values
2016-10-11 22:17:29 +08:00
Mitchell Hashimoto 3e7665db09
terraform: shadow component factory supports closing 2016-10-11 22:17:29 +08:00