Commit Graph

1656 Commits

Author SHA1 Message Date
Mitchell Hashimoto
b35b263015 Merge pull request #11329 from hashicorp/f-destroy-prov
Destroy Provisioners
2017-01-26 14:32:21 -08:00
Mitchell Hashimoto
0b0114c9bf Merge pull request #11426 from hashicorp/f-new-graph
core: Refresh, Validate, Input on new graph builders
2017-01-26 14:31:03 -08:00
Radek Simko
0bafea87bb release: clean up after v0.8.5 2017-01-26 16:18:34 +00:00
Radek Simko
b4d477660b
v0.8.5 2017-01-26 16:01:59 +00:00
Mitchell Hashimoto
ae6bf241ec
terraform: validate self references 2017-01-25 21:00:45 -08:00
Mitchell Hashimoto
4a9cafcd67
terraform: expand count on resources during validation 2017-01-25 12:39:08 -08:00
Mitchell Hashimoto
86cbcff962
terraform: fixup a merge issue
We forgot to wrap some changes from the old branch into the new style
2017-01-25 12:32:09 -08:00
Mitchell Hashimoto
1427075005
terraform: wip moving validation to new graph 2017-01-25 12:28:07 -08:00
Mitchell Hashimoto
66f6f70cdb
terraform: input graph 2017-01-25 12:28:07 -08:00
Mitchell Hashimoto
b2fb3b1d0f
terraform: import graph should setup parent refs to providers
Fixes #11212

The import graph builder was missing the transform to setup links to
parent providers, so provider inheritance didn't work properly. This
adds that.

This also removes the `PruneProviderTransform` since that has no value
in this graph since we'll never add an unused provider.
2017-01-24 15:36:45 -08:00
Mitchell Hashimoto
290ad37489
terraform: test case for #11282 2017-01-24 12:56:13 -08:00
Mitchell Hashimoto
7c014b84b6
terraform: handle count fields for data sources 2017-01-22 16:05:10 -08:00
Mitchell Hashimoto
38286fe491
terraform: Refresh supports new data sources 2017-01-22 13:00:01 -08:00
Mitchell Hashimoto
9c16489887
terraform: ConfigTransformer has Unique and mode filters 2017-01-22 12:58:18 -08:00
Mitchell Hashimoto
d0b7a4a072
terraform: StateFilter handles cases where ResourceState has no type
This was possible with test fixtures but it is also conceiably possible
with older states or corrupted states. We can also extract the type from
the key so we do that now so that StateFilter is more robust.
2017-01-21 10:24:03 -08:00
Mitchell Hashimoto
2055885a0f
website: add destroy provisioners to getting started 2017-01-21 08:31:18 -08:00
Mitchell Hashimoto
a50003d9f6
terraform: fix compilation by complying with interface 2017-01-20 20:45:06 -08:00
Mitchell Hashimoto
d3df7874d5
terraform: introduce EvalApplyPre so that PreApply is called even for
destroy provisioners.
2017-01-20 20:36:53 -08:00
Mitchell Hashimoto
f40fdde708
terraform: PostProvision hook gets the error from the provision step 2017-01-20 20:21:12 -08:00
Mitchell Hashimoto
b56ee1a169
terraform: test on_failure with non-destroy provisioners 2017-01-20 20:05:28 -08:00
Mitchell Hashimoto
4a8c2d0958
terraform: on_failure for provisioners 2017-01-20 19:55:32 -08:00
Mitchell Hashimoto
85cb3a16b0
terraform: on destroy prov failure, don't taint and preserve state 2017-01-20 18:26:41 -08:00
Mitchell Hashimoto
e9f6c9c429
terraform: run destroy provisioners on destroy 2017-01-20 18:07:51 -08:00
James Bardin
89259a1b00 Fix the removal of empty containers from a flatmap
Removal of empty nested containers from a flatmap would sometimes fail a
sanity check when removed in the wrong order. This would only fail
sometimes due to map iteration. There was also an off-by-one error in
the prefix check which could match the incorrect keys.
2017-01-20 16:23:10 -05:00
James Bardin
2820845f8c Remove 0 counts from flatmap during MergeDiff
When a InstanceState is merged with an InstanceDiff, any maps arrays or
sets that no longer exist are shown as empty with a count of 0. If these
are left in the flatmap structure, they will cause errors during
expansion because their existing in the map affects the counts for
parent structures.
2017-01-17 15:49:50 -05:00
clint
f895f93769 release: clean up after v0.8.4 2017-01-11 17:21:31 +00:00
clint
a791ff09b2
v0.8.4 2017-01-11 17:03:56 +00:00
stack72
288996f69c release: clean up after v0.8.3 2017-01-10 09:10:37 +00:00
stack72
b845cb7093
v0.8.3 2017-01-10 09:03:50 +00:00
Andrew Garrett
497010ce42 Fix string representation of sets during interpolation
The change in #10787 used flatmap.Expand to fix interpolation of nested
maps, but it broke interpolation of sets such that their elements were
not represented. For example, the expected string representation of a
splatted aws_network_interface.whatever.*.private_ips should be:

```
[{Variable (TypeList): [{Variable (TypeString): 10.41.17.25}]} {Variable (TypeList): [{Variable (TypeString): 10.41.22.236}]}]
```

But instead it became:

```
[{Variable (TypeList): [{Variable (TypeString): }]} {Variable (TypeList): [{Variable (TypeString): }]}]
```

This is because the expandArray function of expand.go treated arrays to
exclusively be lists, e.g. not sets. The old code used to match for
numeric keys, so it would work for sets, whereas expandArray just
assumed keys started at 0 and ascended incrementally. Remember that
sets' keys are numeric, but since they are hashes, they can be any
integer. The result of assuming that the keys start at 0 led to the
recursive call to flatmap.Expand not matching any keys of the set, and
returning nil, which is why the above example has nothing where the IP
addresses used to be.

So we bring back that matching behavior, but we move it to expandArray
instead. We've modified it to not reconstruct the data structures like
it used to when it was in the Interpolator, and to use the standard int
sorter rather than implementing a custom sorter since a custom one is no
longer necessary thanks to the use of flatmap.Expand.

Fixes #10908, and restores the viability of the workaround I posted in #8696.

Big thanks to @jszwedko for helping me with this fix. I was able to
diagnose the problem along, but couldn't fix it without his help.
2016-12-23 23:37:03 +00:00
Mitchell Hashimoto
fc6e2a1b79 release: clean up after v0.8.2 2016-12-21 20:15:38 +00:00
Mitchell Hashimoto
dd2c6da4f6
v0.8.2 2016-12-21 20:03:36 +00:00
James Bardin
084670c241 Use flatmap.Expand to extract interpolated values
Now that flatmap.Expand will properly expand nested maps, we can use
that to extract any lists and maps when interpolating.
2016-12-16 10:36:27 -05:00
James Bardin
ec2550dea5 Sort interpolated lists by index
Interpolated lists should be sorted by index number, rather than
lexicographic key order.
2016-12-15 16:45:59 -05:00
James Bardin
61982be9c6 failing test with wrong interpolated list order
The plan diffs for aws_instance.a and aws_instance.b should be
identical.
2016-12-15 13:23:50 -05:00
James Bardin
d026745823 Allow test fixtures with non-string attributes
The testDiffFn was only only allowing string values for attributes
2016-12-15 12:03:17 -05:00
Mitchell Hashimoto
9853935876 release: clean up after v0.8.1 2016-12-15 06:14:59 +00:00
Mitchell Hashimoto
a54c3478b4
v0.8.1 2016-12-15 06:10:22 +00:00
Mitchell Hashimoto
817a593280
terraform: destroy edges should take into account module variables
Fixes #10729

Destruction ordering wasn't taking into account ordering implied through
variables across module boundaries.

This is because to build the destruction ordering we create a
non-destruction graph to determine the _creation_ ordering (to properly
flip edges). This creation graph we create wasn't including module
variables. This PR adds that transform to the graph.
2016-12-14 21:48:09 -08:00
Mitchell Hashimoto
89f7e3b79f
terraform: add module vars after providers to see references
Fixes #10711

The `ModuleVariablesTransformer` only adds module variables in use. This
was missing module variables used by providers since we ran the provider
too late. This moves the transformer and adds a test for this.
2016-12-13 21:22:21 -08:00
Mitchell Hashimoto
a04ce1d09a release: clean up after v0.8.0 2016-12-13 18:20:33 +00:00
Mitchell Hashimoto
142dd256ad
v0.8.0 2016-12-13 18:16:00 +00:00
Mitchell Hashimoto
5f1e6ad020
terraform: TargetsTransformer should preserve module variables
Fixes #10680

This moves TargetsTransformer to run after the transforms that add
module variables is run. This makes targeting work across modules (test
added).

This is a bug that only exists in the new graph, but was caught by a
shadow error in #10680. Tests were added to protect against regressions.
2016-12-12 20:59:14 -08:00
James Bardin
ed3517858f Merge pull request #10670 from hashicorp/jbardin/GH-10603
Prevent data sources from being aplied early
2016-12-12 14:53:03 -05:00
Mitchell Hashimoto
80eab1d749 Merge pull request #10659 from hashicorp/b-multi-provider-dep
terraform: destroy resources in dependent providers first
2016-12-12 11:49:18 -08:00
Mitchell Hashimoto
8e19a8b79f Merge pull request #10657 from hashicorp/b-unknown-computed-list
terraform: allow indexing into a computed list for multi-count resources
2016-12-12 10:52:27 -08:00
James Bardin
d2c6f1b57f Prevent data sources from being aplied early
If a data source has explicit dependencies in `depends_on`, we can
assume the user has added those because of a dependency not tracked
directly in the config. If there are any entries in `depends_on`, don't
apply the data source early during Refresh.
2016-12-12 10:35:10 -05:00
Mitchell Hashimoto
b346ba32d1
terraform: dependent provider resources are destroyed first in modules
This extends the prior commit to also verify (and fix) that resources of
dependent providers are destroyed first even when they're within
modules.
2016-12-10 20:22:12 -05:00
Mitchell Hashimoto
14d079f914
terraform: destroy resources in dependent providers first
Fixes #4645

This is something that never worked (even in legacy graphs), but as we
push forward towards encouraging multi-provider usage especially with
things like the Vault data source, I want to make sure we have this
right for 0.8.

When you have a config like this:

```
resource "foo_type" "name" {}
provider "bar" { attr = "${foo_type.name.value}" }
resource "bar_type" "name" {}
```

Then the destruction ordering MUST be:

  1. `bar_type`
  2. `foo_type`

Since configuring the client for `bar_type` requires accessing data from
`foo_type`. Prior to this PR, these two would be done in parallel. This
properly pushes forward the dependency.

There are more cases I want to test but this is a basic case that is
fixed.
2016-12-10 20:11:24 -05:00
Mitchell Hashimoto
cabcc4b5b8
terraform: allow indexing into a computed list for multi-count resources
Fixes #8695

When a list count was computed in a multi-resource access
(foo.bar.*.list), we were returning the value as empty string. I don't
actually know the histocal reasoning for this but this can't be correct:
we must return unknown.

When changing this to unknown, the new tests passed and none of the old
tests failed. This leads me further to believe that the return empty
string is probably a holdover from long ago to just avoid crashes or
UUIDs in the plan output and not actually the correct behavior.
2016-12-10 19:17:29 -05:00