Commit Graph

1179 Commits

Author SHA1 Message Date
Paul Hinze
78f5780248 core: output "diffs didn't match" error details
Previously these details were relegated to the debug logs, which forces
the user to reproduce the error condition and then go digging for the
error message. Since we're asking users to report this error, let's give
them all the details they need right up front to make it a little easier
on them.
2016-02-23 13:41:18 -06:00
Paul Hinze
fbc9cf9ddb core: error instead of panic on self var in wrong scope
Fixes #4808
Fixes #5174
2016-02-23 11:44:24 -06:00
Paul Hinze
5a9dad82d6 terraform: upgrade resource name regexp failure to error
We're well past Terraform 0.4, so it's time to finally make good on the
original promise. :)

Fixes #5243
2016-02-23 10:32:49 -06:00
Paul Hinze
136c228b48 core: add context test for #5096 2016-02-22 18:37:21 -06:00
Paul Hinze
3d2bd8576a Merge pull request #5096 from paybyphone/paybyphone_create_before_destroy_bypass
Bypass CreateBeforeDestroyTransformer on terraform destroy
2016-02-22 18:34:36 -06:00
James Nugent
bc6107508d Fix additional vet warnings 2016-02-17 11:59:50 -08:00
Chris Marchesi
4a22ac5ea0 Bypass CreateBeforeDestroyTransformer during terraform destroy 2016-02-10 20:08:36 -08:00
Paul Hinze
9a00675262 Merge pull request #5026 from hashicorp/phinze/destroy-node-copies
core: Make copies when creating destroy nodes
2016-02-09 11:12:01 -06:00
Paul Hinze
4c123dbf96 Merge pull request #5022 from hashicorp/phinze/fix-provider-double-init-for-nested-module-orphans
core: fix bug detecting deeply nested module orphans
2016-02-09 11:02:37 -06:00
Paul Hinze
e76fdb92e7 core: fix bug detecting deeply nested module orphans
Context:

As part of building up a Plan, Terraform needs to detect "orphaned"
resources--resources which are present in the state but not in the
config. This happens when config for those resources is removed by the
user, making it Terraform's responsibility to destroy them.

Both state and config are organized by Module into a logical tree, so
the process of finding orphans involves checking for orphaned Resources
in the current module and for orphaned Modules, which themselves will
have all their Resources marked as orphans.

Bug:

In #3114 a problem was exposed where, given a module tree that looked
like this:

```
root
 |
 +-- parent (empty, except for sub-modules)
       |
       +-- child1 (1 resource)
       |
       +-- child2 (1 resource)
```

If `parent` was removed, a bunch of error messages would occur during
the plan. The root cause of this was duplicate orphans appearing for the
resources in child1 and child2.

Fix:

This turned out to be a bug in orphaned module detection. When looking
for deeply nested orphaned modules, root.parent was getting added twice
as an orphaned module to the graph.

Here, we add an additional check to prevent a double add, which
addresses this scenario properly.

Fixes #3114 (the Provisioner side of it was fixed in #4877)
2016-02-09 10:35:46 -06:00
Paul Hinze
3f72837f4b core: Make copies when creating destroy nodes
Fixes an interpolation race that was occurring when a tainted destroy
node and a primary destroy node both tried to interpolate a computed
count in their config. Since they were sharing a pointer to the _same_
config, depending on how the race played out one of them could catch the
config uninterpolated and would then throw a syntax error.

The `Copy()` tree implemented for this fix can probably be used
elsewhere - basically we should copy the config whenever we drop nodes
into the graph - but for now I'm just applying it to the place that
fixes this bug.

Fixes #4982 - Includes a test covering that race condition.
2016-02-09 09:25:16 -06:00
Sander van Harmelen
f6822dcb7d Merge pull request #4999 from svanharmelen/f-rename-missing-provider-node
Rename `graphNodeMissingProvider` to `graphNodeProvider`
2016-02-08 20:32:03 +01:00
Paul Hinze
0846e32e21 Merge pull request #4877 from svanharmelen/b-provisioner-graphing
core: fix the provisioner graphing
2016-02-05 12:39:19 -06:00
Sander van Harmelen
e938a645c5 Rename graphNodeMissingProvider to graphNodeProvider
It seems `graphNodeProvider` is a more descriptive name for this node…
2016-02-04 21:41:04 +01:00
Sander van Harmelen
1bec11472a Cleaning up the PruneProvisionerTransformer
And renamed some types so they better reflect what they are for.
2016-02-04 21:32:10 +01:00
Mitchell Hashimoto
8be4afacf8 terraform: replace config/lang usage 2016-02-03 13:24:04 -05:00
David Harris
d95ab75565 Added EvalIgnoreChanges on diffApply. 2016-02-02 15:23:25 -07:00
clint
dce2994151 release: clean up after v0.6.11 2016-02-01 20:17:08 +00:00
clint
3590cfadb0
v0.6.11 2016-02-01 19:16:01 +00:00
Sander van Harmelen
5c3da47d8e Fix the provisioner graphing
Without this change, all provisioners are added to the graph by default
and they are never pruned from the graph if their not needed.
2016-01-28 16:14:15 +01:00
Paul Hinze
2dca1ea9a0 release: clean up after v0.6.10 2016-01-27 17:01:41 -06:00
Paul Hinze
22481b06f5
v0.6.10 2016-01-27 22:18:55 +00:00
Paul Hinze
48b172aa86 core: treat refs to unknown set resource attrs as unknown
References to computed list-ish attributes (set, list, map) were being
improperly resolved as an empty list `[]` during the plan phase (when
the value of the reference is not yet known) instead of as an
UnknownValue.

A "diffs didn't match" failure in an AWS DirectoryServices test led to
this discovery (and this commit fixes the failing test):

https://travis-ci.org/hashicorp/terraform/jobs/104812951

Refs #2157 which has the original work to support computed list
attributes at all. This is just a simple tweak to that work.

/cc @radeksimko
2016-01-26 13:50:44 -06:00
James Nugent
cb6cb8b96a core: Support explicit variable type declaration
This commit adds support for declaring variable types in Terraform
configuration. Historically, the type has been inferred from the default
value, defaulting to string if no default was supplied. This has caused
users to devise workarounds if they wanted to declare a map but provide
values from a .tfvars file (for example).

The new syntax adds the "type" key to variable blocks:

```
variable "i_am_a_string" {
    type = "string"
}

variable "i_am_a_map" {
    type = "map"
}
```

This commit does _not_ extend the type system to include bools, integers
or floats - the only two types available are maps and strings.

Validation is performed if a default value is provided in order to
ensure that the default value type matches the declared type.

In the case that a type is not declared, the old logic is used for
determining the type. This allows backwards compatiblity with previous
Terraform configuration.
2016-01-24 11:40:02 -06:00
Paul Hinze
8d8b28717e Merge pull request #4574 from hashicorp/phinze/orphan-addressing
Orphan addressing / targeting
2016-01-21 15:07:41 -06:00
Paul Hinze
545aaf1864 core: demote evaltree loglevel from INFO -> TRACE
One small step in the long road to making our log levels actually
useful. :)
2016-01-21 10:20:53 -06:00
Paul Hinze
7d10d454e2 Merge pull request #4749 from hashicorp/b-1752
core: fix diff mismatch when RequiresNew field and list both change
2016-01-19 18:29:10 -06:00
Paul Hinze
a0d3245ee3 core: Orphan addressing / targeting
Instead of trying to skip non-targeted orphans as they are added to
the graph in OrphanTransformer, remove knowledge of targeting from
OrphanTransformer and instead make the orphan resource nodes properly
addressable.

That allows us to use existing logic in TargetTransformer to filter out
the nodes appropriately. This does require adding TargetTransformer to the
list of transforms that run during DynamicExpand so that targeting can
be applied to nodes with expanded counts.

Fixes #4515
Fixes #2538
Fixes #4462
2016-01-19 17:48:44 -06:00
Paul Hinze
4af2c5f5dd core: fix diff mismatch when RequiresNew field and list both change
fixes #1752

Includes AccTest reproducing example from the issue as well as a bunch
of explanatory comments in the tests and impls.
2016-01-19 15:38:04 -06:00
Mitchell Hashimoto
54de9057ba terraform: failing test case 2016-01-19 12:37:55 -08:00
Clint
f9113ad40e release: clean up after v0.6.9 2016-01-08 19:03:25 +00:00
Clint
fd1c2697a4
v0.6.9 2016-01-08 17:43:57 +00:00
Paul Hinze
f80655b1ce release: clean up after v0.6.8 2015-12-02 15:32:07 +00:00
Paul Hinze
f1f214f03d
v0.6.8 2015-12-02 15:06:55 +00:00
Paul Hinze
0e277a6714 core: test coverage around map key regression
tests to cover the HCL-level issue fixed in
https://github.com/hashicorp/hcl/pull/65
2015-11-24 16:00:02 -06:00
clint shryock
73e1f4ce52 release: clean up after v0.6.7 2015-11-23 15:46:11 -06:00
clint shryock
b7c41aed92
v0.6.7 2015-11-23 18:16:01 +00:00
Paul Hinze
993ec0a320 Merge pull request #3909 from hashicorp/phinze/template-file-contents
template_file: source contents instead of path
2015-11-16 14:50:45 -06:00
James Nugent
38bb9f2416 Allow targeting of orphan nodes
Fixes #3852. We now run the OrphanTransformer even when targeting, and
pass it the list of targets following resource expansion.
2015-11-13 14:33:58 -06:00
James Nugent
bfb770ee89 Add failing test for targeted destroy on orphan
This replicates the issue reported in #3852.
2015-11-13 13:20:04 -06:00
Paul Hinze
928f534cfc template_file: source contents instead of path
Building on the work of #3846, deprecate `filename` in favor of a
`template` attribute that accepts file contents instead of a path.

Required a bit of work in the interpolation code to prevent Terraform
from assuming that template interpolations were resource variables that
needed to be resolved. Leaving them as "Unknown Variables" prevents
interpolation from happening early and lets the `template_file` resource
do its thing.
2015-11-13 11:24:20 -06:00
James Nugent
2a0334125c Add test attempting to reproduce #2598
This attempts to reproduce the issue described in #2598 whereby outputs
added after an apply are not reflected in the output. As per the issue
the outputs are described using the JSON syntax.
2015-11-09 15:27:09 -05:00
James Nugent
f4c03ec2a6 Reflect new comment format in stringer.go
As of November 8th 2015, (4b07c5ce8a), the word "Code" is prepended to
the comments in Go source files generated by the stringer utility.
2015-11-09 11:38:51 -05:00
stack72
89ce6f7c83 Started the work for the AWS CodeCommit Repository resource
Starting to add the skeleton for the creation and update of a repository
2015-10-30 21:39:04 +00:00
Paul Hinze
715437537d command: fix flaky parallelism tests
Thanks to @mitchellh for helping sort out concurrency stuff here.
2015-10-29 15:16:34 -05:00
Paul Hinze
81ffb72230 release: clean up after v0.6.6 2015-10-23 10:50:35 -05:00
Paul Hinze
d83cb911cd v0.6.6 2015-10-23 15:31:41 +00:00
Paul Hinze
d2034a26b2 release: clean up after v0.6.5 2015-10-21 11:34:52 -05:00
Paul Hinze
5ea09afad5 v0.6.5 2015-10-21 10:47:56 -05:00
Paul Hinze
05c0998d2d core: store deeply nested modules in a consistent order in the state
We were only comparing the last element of the module, which meant that
deeply nested modules with the same name but different ancestry had an
undefined sort order, which could cause inconsistencies in state
storage and potentially break remote state MD5 checksumming.
2015-10-20 14:35:57 -05:00
Paul Hinze
fca44bdec3 core: state metadata difference should bump serial
Remote state includes MD5-based checksumming to protect against State
conflicts. This can generate improper conflicts with states that differ
only in their Schema version.

We began to see this issue with
https://github.com/hashicorp/terraform/pull/3470 which changes the
"schema_version" of aws_key_pairs.
2015-10-20 12:28:12 -05:00
Mitchell Hashimoto
263cc1b855 terraform: final failing test 2015-10-15 13:52:27 -07:00
clint shryock
1bfd4b0f71 Reset CHANGELOG/version for 0.6.5 release 2015-10-15 17:50:20 +00:00
clint shryock
49396ba3e0 v0.6.4 2015-10-15 15:51:15 +00:00
Paul Hinze
562a793430 style: ran go fmt 2015-10-15 10:21:20 -05:00
Rob Zienert
a1939e70f7 Adding ignore_changes lifecycle meta property 2015-10-14 16:34:27 -05:00
Martin Atkins
8173cd25bb Demote some log lines to DEBUG.
Now that we support log line filtering (as of 0090c063) it's good to be
a bit more fussy about what log levels are assigned to different things.

Here we make a few things that are implementation details log as DEBUG,
and prevent spurious errors from EvalValidateCount where it was returning
an empty EvalValidateError rather than nil when everything was okay.
2015-10-11 10:45:33 -07:00
Martin Atkins
3c939f9b26 Merge #3239: "compact" interpolation function 2015-10-10 15:18:10 -07:00
Anthony Stanton
3040d8419f Test removing weird zero+zero Route53 test case 2015-10-08 18:07:07 +02:00
Panagiotis Moustafellos
e4845f75cc removed extra parentheses 2015-10-08 15:48:04 +03:00
Radek Simko
3a05f01553 Treat missing variables during destroy as unknown 2015-10-03 14:16:40 -07:00
Radek Simko
40b04154fe Add operation walkDestroy 2015-10-03 14:16:40 -07:00
Radek Simko
2b60d0c6b6 Add repro test case for bug #2892 2015-10-03 14:16:39 -07:00
Paul Hinze
c39fdd2917 Merge pull request #2988 from hashicorp/b-input-var-partially-computed
core: don't error on computed value during input walk
2015-09-24 15:07:49 -05:00
Anthony Scalisi
198e1a5186 remove various typos 2015-09-11 11:56:20 -07:00
Radek Simko
91d750d2df interpolate: Expand computed TypeList attributes properly 2015-08-27 13:02:02 +01:00
Paul Hinze
c618132085 tests: fix missed test update from last merge 2015-08-13 10:11:12 -05:00
Paul Hinze
22ea3d693f update prevent_destroy error message
per recommendations by @nathanielks

closes #2473
2015-08-13 09:57:52 -05:00
Paul Hinze
b928777cac core: don't error on computed value during input walk
fixes #2987
2015-08-12 14:23:33 -05:00
Clint Shryock
58d8ae8b51 release: cleanup after v0.6.3 2015-08-11 11:42:54 -05:00
Clint Shryock
234f49a2c9 v0.6.3 2015-08-11 15:45:58 +00:00
Paul Hinze
52c4bfbe98 core: fix deadlock when dependable node replaced with non-dependable one
In #2884, Terraform would hang on graphs with an orphaned resource
depended on an orphaned module.

This is because orphan module nodes (which are dependable) were getting
expanded (replaced) with GraphNodeBasicSubgraph nodes (which are _not_
dependable).

The old `graph.Replace()` code resulted in GraphNodeBasicSubgraph being
entered into the lookaside table, even though it is not dependable.

This resulted in an untraversable edge in the graph, so the graph would
hang and wait forever.

Now, we remove entries from the lookaside table when a dependable node
is being replaced with a non-dependable node. This means we lose an
edge, but we can move forward. It's ~probably~ never correct to be
replacing depenable nodes with non-dependable ones, but this tweak
seemed preferable to tossing a panic in there.
2015-08-10 15:50:36 -05:00
Paul Hinze
7a464b1156 tests: extract deadlock checking test helper 2015-08-10 15:50:36 -05:00
Clint Shryock
fd2b943c9d release: clean up after v0.6.2 2015-08-06 14:35:18 -05:00
Clint Shryock
f26d2b75c8 v0.6.2 2015-08-06 18:59:05 +00:00
Paul Hinze
5ebbda3334 core: fix crash on provider warning
When a provider validation only returns a warning, we were cutting the
evaltree short by returning an error. This is fine during a
`walkValidate` but was causing trouble during `walkPlan` and
`walkApply`.

fixes #2870
2015-07-28 17:13:14 -05:00
Radek Simko
a22dc2a9a2 Add resource ID to refresh errors 2015-07-22 14:09:39 +02:00
Radek Simko
8e477b78d8 Add resource ID to errors coming from apply 2015-07-22 14:09:34 +02:00
Clint Shryock
7110364298 release: clean up after v0.6.1 2015-07-20 16:03:53 -05:00
Clint Shryock
4c67368dd8 v0.6.1 2015-07-20 20:03:29 +00:00
Mitchell Hashimoto
8d29f274c8 terraform: remove print 2015-07-20 08:57:35 -07:00
Mitchell Hashimoto
696d5ef94f terraform: clarify comment 2015-07-20 08:57:35 -07:00
Mitchell Hashimoto
4d361c839e terraform: prune resources and variables 2015-07-20 08:57:34 -07:00
Mitchell Hashimoto
6550f564bf terraform: PruneNoopTransformer 2015-07-20 08:57:34 -07:00
Mitchell Hashimoto
853f4f2385 Merge pull request #2786 from hashicorp/b-nested-module-orphans
Grandchild module orphans should be destroyed
2015-07-20 08:52:33 -07:00
Mitchell Hashimoto
955bbbba41 terraform: state module orphans should only return direct 2015-07-20 08:41:24 -07:00
Paul Hinze
392f56101c core: add failing deeply nested orphan module test
I was worried about the implications of deeply nested orphaned modules
in the parent commit, so I added a test. It's failing but not quite like
I expected it to. Perhaps I've uncovered an unrelated bug here?

/cc @mitchellh
2015-07-20 10:19:52 -05:00
Mitchell Hashimoto
7735847579 terraform: splatting with computed values is computed [GH-2744] 2015-07-19 17:27:38 -07:00
Mitchell Hashimoto
edd05f2aa2 terraform: fix some test failures 2015-07-19 14:14:05 -07:00
Mitchell Hashimoto
61d275f475 terraform: get nested oprhans in the transform 2015-07-19 13:53:31 -07:00
Mitchell Hashimoto
96a04c16f6 terraform: state ModuleOrphans should return grandchild orphans 2015-07-19 13:41:57 -07:00
Mitchell Hashimoto
2ee46eda94 test case 2015-07-17 10:58:47 -07:00
Paul Hinze
f97c635ef6 core: fix "provider ... couldn't be found" bug
The `CloseProviderTransformer` relies on the `ProvidedBy()` interface to
look up the proper dependency for the the graph nodes it adds. This
interface needs to yield the name of a provider, _AND_ for flattened
nodes it needs to yield the full path to a provider.

Destroy nodes did not implement this second part, which resulted in
"provider X couldn't be found" when both of these were true:

 * A module included a resource that dependend on a provider
 * The root did _NOT_ include a provider config

Implementing a proper ProvidedBy() on the flattened version of
destroy nodes solves the issue.

fixes #2581
2015-07-16 11:56:58 -05:00
Paul Hinze
ff45f6451d core: split context tests
The context_test file has gotten pretty unruly. Let's split it up into
a few files so we can be nicer to our editors and our own sanity.

Definitely lots more we can do to clean up, but with changes like this
I'd rather do small, focused, clear steps instead of one big "cleaned up
lots of stuff" PR.
2015-07-10 14:08:49 -06:00
Sander van Harmelen
4a8ef78d33 Fixes #2676 by prefixing all Windows commands
By prefixing them with `cmd /c` it will work with both `winner` and
`ssh` connection types.

This PR also reverts some bad stringer changes made in PR #2673
2015-07-10 12:56:27 +02:00
Sander van Harmelen
97fd4f5b7d Tweaking the tests 2015-07-09 21:29:27 +02:00
Paul Hinze
5c38456b05 core: don't prompt for variables with defaults
In `helper/schema` we already makes a distinction between `Default`
which is always applied and `InputDefault` which is displayed to the
user for an empty field.

But for variables we just have `Default` which is treated like
`InputDefault`. This changes it to _not_ prompt the user for a value
when the variable declaration includes a default.

Treating this as a UX bugfix and the "don't prompt for variables w/
defaults set" behavior as the originally expected behavior we were
failing to honor.

Added an already-passing test to verify and cover the `helper/schema`
behavior.

Perhaps down the road we can add a `input_default` attribute to
variables to allow similar behavior to `helper/schema` in variables, but
for now just sticking with the fix.

Fixes #2592
2015-07-02 10:40:30 -05:00
Paul Hinze
3d81d83d01 release: clean up after 0.6.0 2015-06-30 17:39:32 -05:00
Paul Hinze
e40127fda6 v0.6.0 2015-06-30 19:57:29 +00:00
Paul Hinze
6bbf61ae6e Merge pull request #2555 from hashicorp/b-target-after-flatten
core: move targets transform after flatten
2015-06-29 13:34:52 -05:00
Paul Hinze
cf432b3ceb core: move targets transform after flatten
Allows target dependencies to be properly calculated across module
boundaries, fixing scenarios where a target depends on something inside
a module, but the contents of the module are not included in the
targeted resources.

fixes #1858
2015-06-29 13:19:37 -05:00
Paul Hinze
184edbefcd core: remove now-unused flatten impls of close nodes
/cc @mitchellh
2015-06-29 12:46:24 -05:00
Paul Hinze
557b299c4b core: move close transforms after flatten and destroy transforms
fixes destroy-related failures introduced by the close transforms
2015-06-29 12:46:18 -05:00
Mitchell Hashimoto
d6f7261190 terraform: provider mock should close itself to find bugs 2015-06-29 10:33:37 -07:00
Paul Hinze
00a177cd99 provider/aws: add test for provider aliases
Not sure if this test has value /cc @mitchellh (who requested one be
added) to see what I might be missing here.

refs #2495
2015-06-29 11:35:02 -05:00
Paul Hinze
2d6a8c1f39 core: fix provider/close provider race when targeting
When targeting prunes out all the resource nodes between a provider and
its close node, there was no dependency to ensure the close happened
after the configure. Needed to add an explicit dependency from the close
to the provider.

This tweak highlighted the fact that CloseProviderTransformer needed to
happen after DisableProviderTransformer, since
DisableProviderTransformer inspects up-edges to decide what to disable,
and CloseProviderTransformer adds an up-edge.

fixes #2495
2015-06-29 11:22:51 -05:00
Paul Hinze
2626c179a5 core: improve debug logging when targeting 2015-06-26 14:04:58 -05:00
Mitchell Hashimoto
51a7e05f8a terraform: all providers for ProvidedBy() should be added 2015-06-26 12:00:02 -07:00
Mitchell Hashimoto
7daf13487f Merge pull request #2506 from hashicorp/b-orphan-hook
terraform: orphans should call post-apply hook [GH-1938]
2015-06-26 08:19:16 -07:00
Paul Hinze
a81cad3672 Merge pull request #2504 from hashicorp/f-string-list
core: Change string list representation so we can distinguish empty, single element lists
2015-06-26 08:41:38 -05:00
Mitchell Hashimoto
8ebdc1e786 terraform: orphans should call post-apply hook [GH-1938] 2015-06-25 20:11:29 -07:00
Mitchell Hashimoto
a3a2698e56 Merge pull request #2479 from hashicorp/b-validate-fail-early
terraform: fail early if module validation fails
2015-06-25 17:50:35 -07:00
Paul Hinze
e88aeede9b core: allow distinguishing between empty lists and strings
Had to handle a lot of implicit leaning on a few properties of the old
representation:

 * Old representation allowed plain strings to be treated as lists
   without problem (i.e. shoved into strings.Split), now strings need to
   be checked whether they are a list before they are treated as one
   (i.e. shoved into StringList(s).Slice()).
 * Tested behavior of 0 and 1 length lists in formatlist() was a side
   effect of the representation. Needs to be special cased now to
   maintain the behavior.
 * Found a pretty old context test failure that was wrong in several
   different ways. It's covered by TestContext2Apply_multiVar so I
   removed it.
2015-06-25 18:53:35 -05:00
Paul Hinze
10b3abf405 config: introduce StringList to abstract over list hack
This is the initial pure "all tests passing without a diff" stage. The
plan is to change the internal representation of StringList to include a
suffix delimiter, which will allow us to recognize empty and
single-element lists.
2015-06-25 17:55:56 -05:00
Mitchell Hashimoto
592df714eb Merge pull request #2478 from hashicorp/b-invalid-var-should-error
terraform: error if resource not found in module [GH-1997]
2015-06-25 08:56:20 -07:00
Mitchell Hashimoto
c79a661ce1 Merge branch 'b-provider-alias-module' 2015-06-25 08:54:56 -07:00
Mitchell Hashimoto
632cc92897 Merge pull request #2476 from hashicorp/b-orphan-provider-inherit
terraform: module orphans providers should inherit config
2015-06-25 08:50:49 -07:00
Mitchell Hashimoto
ced4701a8c terraform: remove test that was weirdly passing without error 2015-06-24 22:51:29 -07:00
Mitchell Hashimoto
785defc870 terraform: fail early if module validation fails 2015-06-24 22:43:55 -07:00
Mitchell Hashimoto
fcc710ca06 terraform: error if resource not found in module [GH-1997] 2015-06-24 22:25:48 -07:00
Mitchell Hashimoto
54b961630d terraform: module computed vars with splat vars don't error 2015-06-24 21:23:37 -07:00
Mitchell Hashimoto
29eadb8194 terraform: missing provider should add missing aliases [GH-2023] 2015-06-24 20:58:52 -07:00
Mitchell Hashimoto
afe5ec6e29 terraform: module orphans providers should inherit config 2015-06-24 17:48:31 -07:00
Paul Hinze
38efe4cb80 dot: only draw provider close on terraform greph -verbose 2015-06-24 17:36:45 -05:00
Mitchell Hashimoto
148a84cfc3 Merge pull request #2453 from hashicorp/b-orphan-deps
terraform: orphan dependencies should be inverted
2015-06-24 10:31:43 -07:00
Mitchell Hashimoto
c144491f6f Merge pull request #2457 from hashicorp/b-provider-computed
Computed provider variables properly validate
2015-06-24 10:14:35 -07:00
Mitchell Hashimoto
d0519f226d terraform: provider input should be scoped by path
The provider input before wasn't scoped by path, which caused
non-descendant parts of the graph to grab the configuration of another
sub-tree. The result is that you'd often get copied provider
configurations across the module barriers.

See GH-2024
2015-06-24 09:34:21 -07:00
Mitchell Hashimoto
1e739d1237 terraform: validate step should still set parent config for inheritence 2015-06-23 22:18:57 -07:00
Mitchell Hashimoto
772fab3609 terraform: don't config provider on validate 2015-06-23 22:14:54 -07:00
Mitchell Hashimoto
8daa459e57 terraform: tests to check behavior of computed provider configs 2015-06-23 22:02:56 -07:00
Mitchell Hashimoto
7031cb145c terraform: orphan dependencies should be inverted 2015-06-23 20:41:02 -07:00
Mitchell Hashimoto
74386655a5 terraform: test for reducing count and using splats 2015-06-23 18:25:08 -07:00
Sander van Harmelen
783fd57ec2 Merge pull request #2435 from svanharmelen/f-add-loadjson
core: add a function to load JSON directly
2015-06-23 22:38:13 +02:00
Sander van Harmelen
01a9ceeed4 Merge pull request #2406 from svanharmelen/b-close-providers-provisioners
core: close provider/provisioner connections when not used anymore
2015-06-23 22:37:10 +02:00
Sander van Harmelen
110cf8b3d4 A close provider should not be an origin node
Removed the `DotOrigin()` func after review of the PR. With this change
the PR is up-to-spec to be merged (as just discussed with Paul in IRC).
2015-06-23 22:31:44 +02:00
Sander van Harmelen
c62370f9e9 Add a function to load JSON directly
Without this 12 line function it’s impossible to use any of the
Terraform code without the need for having the files on disk. As more
and more people are using (parts of) Terraform in other software, this
seems to be a very welcome addition. It has no negative impact on
Terraform itself whatsoever (the function is never called), but it
opens up a lot of other use cases.

Next to the single new function, I renamed the existing function (and
related tests) to better reflect what the function does. So now there
is a `LoadDir` function which calls `LoadFile` for each file, which
kind of made sense to me, especially when now adding a `LoadJSON`
function as well.

But of course if the rename is a problem, I can revert that part as
it’s not related to the added `LoadJSON` function.

Thanks!
2015-06-23 16:15:26 +02:00
Radek Simko
0fc8882e29 Expose Terraform version internally & externally 2015-06-21 12:24:42 +01:00
Sander van Harmelen
0b1dbf31a3 core: close provider/provisioner connections
Currently Terraform is leaking goroutines and with that memory. I know
strictly speaking this maybe isn’t a real concern for Terraform as it’s
mostly used as a short running command line executable.

But there are a few of us out there that are using Terraform in some
long running processes and then this starts to become a problem.

Next to that it’s of course good programming practise to clean up
resources when they're not needed anymore. So even for the standard
command line use case, this seems an improvement in resource management.

Personally I see no downsides as the primary connection to the plugin
is kept alive (the plugin is not killed) and only unused connections
that will never be used again are closed to free up any related
goroutines and memory.
2015-06-19 21:52:50 +02:00
Clint Shryock
78e7519efa Updates from go generate 2015-06-03 08:37:57 -05:00
Sam Boyer
b82bd0c280 Condense switch fallthroughs into expr lists 2015-05-26 21:52:36 -04:00
Mitchell Hashimoto
b251afb5af terraform: orphan module should flatten 2015-05-14 20:54:33 -07:00
Mitchell Hashimoto
0728e25f43 terraform: env vars are lower priority 2015-05-14 09:58:30 -07:00
Mitchell Hashimoto
fe74d69852 terraform: validation should succeed if env var set [GH-1930] 2015-05-13 20:09:05 -07:00
Mitchell Hashimoto
6982ebc142 Merge pull request #1955 from ctiwald/ct/fix-vet-complaints
Fix three trivial errors 'go vet' discovered.
2015-05-13 18:24:42 -07:00
Christopher Tiwald
2252b83d9a Fix three trivial errors 'go vet' discovered. 2015-05-13 21:23:07 -04:00
Paul Hinze
842d66183b core: respect roots in CBD transform
Because CBD now runs after a RootTransformer, it's now operating on a
graph that _may_ have had a graphNodeRoot added to it (a noop node whose
only purpose is to be a root).

CBD includes a step that tells the destroy node to depend on any parents
of the create node. When one of those parents was "root", this was
causing the destroy node to depend on "root", making it cease to be an
actual root node.

Because graphNodeRoot is a singleton, the follow-up RootTransformer was
not sufficient to slap another root on top - it wasn't being seen as a
fresh node, so edges were just accumulating, and we ended up in a state
with "no roots".

refs #1903 (not sure if this will fix all the "no root found" cases, or
just the one I bumped into)
2015-05-13 17:53:42 -05:00
Paul Hinze
b0eafeb212 core: fix deadlock w/ CBD + modules
fixes #1947

Root cause was a bad edge being made by the CBD transform going from the
flattened destroy node to the unflattened create node, which was no
longer in the graph. The destroy node therefore had a dependency that
could never be satisfied, which locked up the walk.
2015-05-13 13:05:43 -05:00
Paul Hinze
63241c991b core: flatten disabled providers 2015-05-13 11:50:11 -05:00
Paul Hinze
a5e4e3de59 core: flatten orphan modules 2015-05-13 11:33:29 -05:00
Paul Hinze
9c7fb87ca8 core: flatten orphan outputs
Hit the "unflattenable node" error again with these.

This fixes it.
2015-05-12 15:10:21 -05:00
Paul Hinze
0273732dec core: make orphans flattenable
Got this while playing around in a module:

> * unflattenable node: aws_security_group.internal (orphan)
> *terraform.graphNodeOrphanResource

Basically just copied implementation from
d503cc2d82
2015-05-11 22:24:11 -05:00
Mitchell Hashimoto
f86dc22caf terraform: return unknown if resource not found 2015-05-11 14:57:20 -07:00
Mitchell Hashimoto
fc084cc03e Merge pull request #1857 from hashicorp/b-multi-mod
terraform: flattening multi-level modules works
2015-05-07 13:34:35 -07:00
Mitchell Hashimoto
6d56a2ac86 terraform: comment 2015-05-07 13:10:25 -07:00
Mitchell Hashimoto
7c3e355bb0 terraform: flattening multi-level modules works 2015-05-07 13:08:59 -07:00
Mitchell Hashimoto
6752ccfe10 terraform: only include variables in graph if count of a resource
depends
2015-05-07 10:50:56 -07:00
Mitchell Hashimoto
6b2e0b938d terraform: only omit vars on full destroys 2015-05-06 20:55:14 -07:00
Mitchell Hashimoto
19b33326be terraform: don't include variables in destroy node requirements 2015-05-06 20:13:19 -07:00
Paul Hinze
5d50264c31 core: module targeting
Adds the ability to target resources within modules, like:

module.mymod.aws_instance.foo

And the ability to target all resources inside a module, like:

module.mymod

Closes #1434
2015-05-05 21:58:48 -05:00
Paul Hinze
0fff7d1673 core: validate graph w/ diff during plan phase
This reimplements my prior attempt at nipping issues where a plan did
not yield the same cycle an apply did. My prior attempt was to have
ctx.Validate generate a "Verbose" worst-case graph. It turns out that
skipping PruneDestroyTransformer to generate this graph misses important
heuristics that prevent cycles by dropping destroy nodes that are
determined to be unused.

This resulted in Validate improperly failing in scenarios where these
heuristics would have broken the cycle.

We detected the problem during the work on #1781 and worked around the
issue by reverting to the non-Verbose graph in Validate.

This commit accomplishes the original goal in a better way - by
generating the full graph and checking it once Plan has calculated the
diff. This guarantees that any graph issue that would be caught by Apply
will be caught by Plan.
2015-05-05 17:24:44 -05:00
Mitchell Hashimoto
8c34e9a36a terraform: provisionedby prefixed 2015-05-05 13:04:27 -07:00
Mitchell Hashimoto
d503cc2d82 terraform: flattenable graphNodeMissingProvisioner 2015-05-05 12:45:28 -07:00
Mitchell Hashimoto
6d4969f64c terraform: run prune destroy on validate 2015-05-05 12:11:49 -07:00
Paul Hinze
c3ce23c7b4 core: failing test for a bad module cycle
passing output of one module into input of the following module results
in a cycle
2015-05-04 18:58:29 -05:00
Mitchell Hashimoto
13f3daa3b3 terraform: update comment on interpolater stuff 2015-05-04 10:51:34 -07:00
Mitchell Hashimoto
2f3f680505 terraform: update comment 2015-05-04 10:49:34 -07:00
Mitchell Hashimoto
cc0c208364 terraform: skip outputs for destroy graphs 2015-05-02 18:28:26 -07:00
Mitchell Hashimoto
6afc14982a terraform: destroy transform must happen globally 2015-05-02 18:21:00 -07:00
Mitchell Hashimoto
542ddb881a terraform: disable destroy mode for flattened nodes 2015-05-01 18:44:07 -07:00
Mitchell Hashimoto
bbb065d1ad terraform: add edge for missing providers 2015-05-01 18:39:24 -07:00
Mitchell Hashimoto
23b6acc29d terraform: add module destroy node to graph 2015-05-01 18:26:35 -07:00
Mitchell Hashimoto
1f10dfef2d terraform: remove test 2015-05-01 18:17:49 -07:00
Mitchell Hashimoto
8f58367680 terraform: missing providers need to do dependencies 2015-05-01 18:08:06 -07:00
Mitchell Hashimoto
7fd432b076 terraform: providers in flattened graphs should depend on the parent 2015-05-01 16:41:49 -07:00
Mitchell Hashimoto
c207beda36 terraform: set variables in the proper location 2015-05-01 16:29:19 -07:00
Mitchell Hashimoto
94e1bab65d terraform: fill in more flat interfaces 2015-05-01 15:28:41 -07:00
Mitchell Hashimoto
416e7a2077 terraform: missing provider should be flattenable 2015-05-01 15:23:37 -07:00
Mitchell Hashimoto
86d07d3b5b terraform: redo how flattening works 2015-05-01 15:18:40 -07:00
Mitchell Hashimoto
f2e7f505d4 terraform: subpath context setting 2015-05-01 14:19:32 -07:00
Mitchell Hashimoto
9a54dddc85 terraform: eval for variables 2015-05-01 14:10:41 -07:00
Mitchell Hashimoto
e544e1d401 terraform: hook up the proxies 2015-05-01 11:45:42 -07:00
Mitchell Hashimoto
7d28e980a5 terraform: proxy uses custom edge 2015-05-01 11:41:01 -07:00
Mitchell Hashimoto
f24a1533f2 terraform: GraphNodeProxy 2015-05-01 11:38:36 -07:00
Mitchell Hashimoto
a0d9bc0f19 terraform: outputs connect properly 2015-05-01 11:26:58 -07:00
Mitchell Hashimoto
7e838dfae2 terraform: Graph should overrride Remove to clear lookaside 2015-05-01 11:20:57 -07:00
Mitchell Hashimoto
dd14ce9a0b terraform: test that variable deps reach out to parent graph 2015-05-01 11:09:23 -07:00
Mitchell Hashimoto
e542d6efdf terraform: test to verify config variables are variables 2015-05-01 10:56:46 -07:00
Mitchell Hashimoto
3bfef7c374 terraform: wrap variable values and prefix dependencies
(untested yet)
2015-05-01 10:56:05 -07:00
Mitchell Hashimoto
12c30feb0f terraform: start FlattenGraph impl. 2015-04-30 20:46:54 -07:00
Mitchell Hashimoto
5e767f63b9 terraform: move module to its own file 2015-04-30 19:23:52 -07:00
Mitchell Hashimoto
15ca84a682 terraform: module dependencies in graph use full name (FOR THE FUTURE) 2015-04-30 17:19:01 -07:00
Mitchell Hashimoto
90cfade626 terraform: naive flatten 2015-04-30 17:02:39 -07:00
Mitchell Hashimoto
1152ff562b terraform: add variables as graph nodes (no eval yet) 2015-04-30 16:27:20 -07:00
Paul Hinze
430e00c55c Merge pull request #1763 from hashicorp/b-fix-1699
core: fix targeting with non-word chars
2015-04-30 16:34:19 -05:00
Paul Hinze
d30d88e327 Merge pull request #1655 from hashicorp/f-build-graph-during-plan
core: validate on verbose graph to detect some cycles earlier
2015-04-30 16:08:33 -05:00
Paul Hinze
443c7e053f Merge pull request #1544 from hashicorp/b-destroy-target-provisioner
core: fix resource targeting w/ provisioners
2015-04-30 16:03:17 -05:00
Paul Hinze
9295e1eca6 core: fix targeting with non-word chars
Flips the regex strategy to capture everything that's _not_ the next
separator instead of whitelisting `\w`

fixes #1699
2015-04-30 15:49:37 -05:00
Mitchell Hashimoto
873f5a91bb terraform: EvalDeleteOutput and context test 2015-04-29 11:27:12 -07:00
Mitchell Hashimoto
2ca181d42d terraform: add output orphan transformer 2015-04-29 11:18:58 -07:00
Paul Hinze
ce49dd6080 core: graph command gets -verbose and -draw-cycles
When you specify `-verbose` you'll get the whole graph of operations,
which gives a better idea of the operations terraform performs and in
what order.

The DOT graph is now generated with a small internal library instead of
simple string building. This allows us to ensure the graph generation is
as consistent as possible, among other benefits.

We set `newrank = true` in the graph, which I've found does just as good
a job organizing things visually as manually attempting to rank the nodes
based on depth.

This also fixes `-module-depth`, which was broken post-AST refector.
Modules are now expanded into subgraphs with labels and borders. We
have yet to regain the plan graphing functionality, so I removed that
from the docs for now.

Finally, if `-draw-cycles` is added, extra colored edges will be drawn
to indicate the path of any cycles detected in the graph.

A notable implementation change included here is that
{Reverse,}DepthFirstWalk has been made deterministic. (Before it was
dependent on `map` ordering.) This turned out to be unnecessary to gain
determinism in the final DOT-level implementation, but it seemed
a desirable enough of a property that I left it in.
2015-04-27 09:23:47 -05:00
Paul Hinze
5e67657325 core: fix targeting in destroy w/ provisioners
The `TargetTransform` was dropping provisioner nodes, which caused graph
validation to fail with messages about uninitialized provisioners when a
`terraform destroy` was attempted.

This was because `destroy` flops the dependency calculation to try and
address any nodes in the graph that "depend on" the target node. But we
still need to keep the provisioner node in the graph.

Here we switch the strategy for filtering nodes to only drop
addressable, non-targeted nodes. This should prevent us from having to
whitelist nodes to keep in the future.

closes #1541
2015-04-27 08:36:54 -05:00
Paul Hinze
d4b9362518 core: validate on verbose graph to detect some cycles earlier
Most CBD-related cycles include destroy nodes, and destroy nodes were
all being pruned from the graph before staring the Validate walk.

In practice this meant that we had scenarios that would error out with
graph cycles on Apply that _seemed_ fine during Plan.

This introduces a Verbose option to the GraphBuilder that tells it to
generate a "worst-case" graph. Validate sets this to true so that cycle
errors will always trigger at this step if they're going to happen.

(This Verbose option will be exposed as a CLI flag to `terraform graph`
in a second incoming PR.)

refs #1651
2015-04-23 11:07:13 -05:00
Mitchell Hashimoto
af4396aa0d Merge pull request #1621 from hashicorp/f-envs
Set variables from env vars
2015-04-22 15:50:56 +02:00
Mitchell Hashimoto
d2011438f7 Merge pull request #1587 from hashicorp/b-count-deps
terraform: inner-count dependencies work [GH-1540]
2015-04-22 08:10:24 +02:00
Mitchell Hashimoto
5ae9ee4d27 terraform: allow TF_VAR_name to be set to set variables 2015-04-22 06:31:53 +02:00
Mitchell Hashimoto
fa934d96d0 helper/schema: FieldReaderConfig detects computed maps 2015-04-21 22:07:52 +02:00
Mitchell Hashimoto
d3689cea29 terraform: test input with multiple providers 2015-04-20 14:59:03 -07:00
Mitchell Hashimoto
de004d7183 terraform: context test for when provider is missing from state 2015-04-20 14:54:25 -07:00
Matt Good
21b0a03d70 Support for multiple providers of the same type
Adds an "alias" field to the provider which allows creating multiple instances
of a provider under different names. This provides support for configurations
such as multiple AWS providers for different regions. In each resource, the
provider can be set with the "provider" field.

(thanks to Cisco Cloud for their support)
2015-04-20 14:14:34 -07:00
Mitchell Hashimoto
7a1592ff1e terraform: don't panic on input for bad default type [GH-1344] 2015-04-18 16:31:21 -07:00
Mitchell Hashimoto
2fffec9545 terraform: inner-count dependencies work [GH-1540] 2015-04-18 15:56:43 -07:00
Paul Hinze
afe4abb637 core: add prevent_destroy lifecycle flag
When the `prevent_destroy` flag is set on a resource, any plan that
would destroy that resource instead returns an error. This has the
effect of preventing the resource from being unexpectedly destroyed by
Terraform until the flag is removed from the config.
2015-04-17 10:40:04 -05:00
Paul Hinze
347690a73e core: don't crash when count.index is used in the wrong context
It's bad manners! :)

Also adds a validation error up at the configuration layer so the user
sees the case from #1528 as an error message.

fixes #1528
2015-04-15 10:23:53 -05:00
Paul Hinze
6365b3af89 Merge pull request #1515 from hashicorp/b-diff-mismatch-on-instance-replacement
core: avoid diff mismatch on NewRemoved fields during -/+
2015-04-14 17:44:28 -05:00
Paul Hinze
64f0897c82 core: avoid diff mismatch on NewRemoved fields during -/+
fixes #1508

In a DESTROY/CREATE scenario, the plan diff will be run against the
state of the old instance, while the apply diff will be run against an
empty state (because the state is cleared when the destroy node does its
thing.)

For complex attributes, this can result in keys that seem to disappear
between the two diffs, when in reality everything is working just fine.

Same() needs to take into account this scenario by analyzing NewRemoved
and treating as "Same" a diff that does indeed have that key removed.
2015-04-14 17:23:30 -05:00
Mitchell Hashimoto
2934824069 terraform: remove debug 2015-04-14 13:20:23 -07:00
Mitchell Hashimoto
486cde44ec terraform: when pruning destroy, only match exact nodes, or exact counts 2015-04-14 13:17:08 -07:00
Paul Hinze
d49933b0f8 Merge pull request #1514 from hashicorp/f-dead-evaltree-cbd-code
core: remove dead code from pre-deposed refactor
2015-04-14 13:42:50 -05:00
Mitchell Hashimoto
b64fd8401c terraform: prune tainted destroys if no tainted in state [GH-1475] 2015-04-14 10:48:45 -07:00
Paul Hinze
d5f6942755 core: remove dead code from pre-deposed refactor
CBD used to "borrow" the last slot of of the Tainted list in the State,
but as of #1078 it uses its own list. This seems like just a block of
old code that didn't get cleaned up from the refactor. Deposed resources
get their own destroy nodes, so they don't have to mess with the main
destroy node.
2015-04-13 18:33:29 -05:00
Paul Hinze
d168cc1bd1 terraform: add reason to diff mismatch error
Helps with debugging those pesky "diffs did not match" errors.
2015-04-13 09:31:09 -05:00
Paul Hinze
6761424309 Merge pull request #1487 from hashicorp/b-provider-vars-inherit
terraform: fix provider config inheritance during input
2015-04-10 16:35:17 -05:00
Paul Hinze
d1b40de242 terraform: fix provider config inheritance during input
The provider config was not being properly merged across module
boundaries during the Input walk over the graph, so when a provider was
configured at the top level, resources in modules could improperly
trigger a request for input for a provider attribute that's already
defined.
2015-04-10 16:28:47 -05:00
Mitchell Hashimoto
4c3923e32a terraform: return value for resource interpolation on refresh
Instead of returning UnknownVariableValue every time, attempt to return
the real value. If we don't find it, return unknown value. This fixes
removing outputs from state on refresh.
2015-04-10 13:51:22 -07:00
Mitchell Hashimoto
b201983304 terraform: copy RawConfigs 2015-04-09 09:21:38 -07:00
Mitchell Hashimoto
eda2e0fdfc terraform: fix disable provider tests 2015-04-09 08:51:38 -07:00
Mitchell Hashimoto
bcff7e070c terraform: don't prune, but disable, inherited configs [GH-1447] 2015-04-09 08:48:08 -07:00
Mitchell Hashimoto
8a90bd08a3 terraform: test negative case for disable provider transformer 2015-04-08 21:39:56 -07:00
Mitchell Hashimoto
edc97d3afd terraform: expanded resource nodes implement graphNodeConfig 2015-04-08 21:25:17 -07:00
Mitchell Hashimoto
218f147c0c terraform: test fixture modified to not prune provider 2015-04-08 21:25:03 -07:00
Mitchell Hashimoto
36520121b1 terraform: disable providers that are only used by modules 2015-04-08 21:14:19 -07:00
Paul Hinze
816c4b475f core: [tests] fix order dependent test 2015-04-01 11:11:46 -05:00
Paul Hinze
c6300d511c core: formalize resource addressing
Only used in targets for now. The plan is to use this for interpolation
as well.

This allows us to target:

 * individual resources expanded by `count` using bracket / index notation.
 * deposed / tainted resources with an `InstanceType` field after name

Docs to follow.
2015-03-31 15:04:10 -05:00
Paul Hinze
40ebfb5ccc core: fill out context tests for targeted ops 2015-03-31 14:49:38 -05:00
Paul Hinze
97acccd3ed core: targeted operations
Add `-target=resource` flag to core operations, allowing users to
target specific resources in their infrastructure. When `-target` is
used, the operation will only apply to that resource and its
dependencies.

The calculated dependencies are different depending on whether we're
running a normal operation or a `terraform destroy`.

Generally, "dependencies" refers to ancestors: resources falling
_before_ the target in the graph, because their changes are required to
accurately act on the target.

For destroys, "dependencies" are descendents: those resources which fall
_after_ the target. These resources depend on our target, which is going
to be destroyed, so they should also be destroyed.
2015-03-31 14:49:38 -05:00
Paul Hinze
f2968b045c Merge pull request #1316 from hashicorp/b-empty-instancestate-state-migrate-crash
providers/aws: handle empty instancestate in state migration
2015-03-29 08:53:04 -05:00
Seth Vargo
1adb3fbfa0 command: when setting up state, only write back if local is newer 2015-03-26 17:16:54 -07:00
Paul Hinze
f51fb5e127 providers/aws: handle empty instancestate in state migration
fixes #1309
2015-03-26 13:07:04 -05:00
Mitchell Hashimoto
a0839da71a terraform: merge provider configs before validate [GH-1282] 2015-03-25 16:28:52 -07:00
Mitchell Hashimoto
9c6e2cdc21 terraform: make sure our serial is always higher 2015-03-25 15:40:53 -07:00
Mitchell Hashimoto
f68f285f72 terraform: test case for higher S1 serial 2015-03-25 15:39:33 -07:00
Mitchell Hashimoto
0d4c7887c5 terraform: don't increment state if one is nil 2015-03-25 15:38:24 -07:00
Mitchell Hashimoto
5e27bfc040 command/push: read name from the config 2015-03-24 13:30:23 -07:00
Mitchell Hashimoto
22087181af command/push: archive, upload 2015-03-24 13:30:22 -07:00
Mitchell Hashimoto
2dce764d75 terraform: add input mode to only ask for unset variables
This adds a new input mode for Context.Input() that will only ask for
variable values that are not set.
2015-03-24 13:30:21 -07:00
Paul Hinze
3ba8ed536b helper/schema: record schema version on apply
We were previously only recording the schema version on refresh. This
caused the state to be incorrectly written after a `terraform apply`
causing subsequent commands to run the state through an unnecessary
migration.
2015-03-18 19:08:48 -05:00
Paul Hinze
3d4b55e557 helper/schema: schema versioning & migration
Providers get a per-resource SchemaVersion integer that they can bump
when a resource's schema changes format. Each InstanceState with an
older recorded SchemaVersion than the cureent one is yielded to a
`MigrateSchema` function to be transformed such that it can be addressed
by the current version of the resource's Schema.
2015-03-06 16:26:11 -06:00
Paul Hinze
f1c9e32fa0 core: tweaks from code review 2015-03-05 10:11:14 -06:00
Paul Hinze
6e13aacefa core: [refactor] DRY up EvalWriteState nodes
Also some final comment cleanup
2015-03-04 18:22:18 -06:00
Paul Hinze
6c93fbb85d core: [refactor] store Deposed resource instances as a list
Deposed instances need to be stored as a list for certain pathological
cases where destroys fail for some reason (e.g. upstream API failure,
Terraform interrupted mid-run). Terraform needs to be able to remember
all Deposed nodes so that it can clean them up properly in subsequent
runs.

Deposed instances will now never touch the Tainted list - they're fully
managed from within their own list.

Added a "multiDepose" test case that walks through a scenario to
exercise this.
2015-03-04 12:25:59 -06:00