Commit Graph

237 Commits

Author SHA1 Message Date
Mitchell Hashimoto
7735847579 terraform: splatting with computed values is computed [GH-2744] 2015-07-19 17:27:38 -07:00
Mitchell Hashimoto
2ee46eda94 test case 2015-07-17 10:58:47 -07: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
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
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
Mitchell Hashimoto
8ebdc1e786 terraform: orphans should call post-apply hook [GH-1938] 2015-06-25 20:11:29 -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
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
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
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
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
Mitchell Hashimoto
b251afb5af terraform: orphan module should flatten 2015-05-14 20:54:33 -07: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
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
7c3e355bb0 terraform: flattening multi-level modules works 2015-05-07 13:08:59 -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
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
6afc14982a terraform: destroy transform must happen globally 2015-05-02 18:21:00 -07:00
Mitchell Hashimoto
bbb065d1ad terraform: add edge for missing providers 2015-05-01 18:39:24 -07:00
Mitchell Hashimoto
a0d9bc0f19 terraform: outputs connect properly 2015-05-01 11:26:58 -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
12c30feb0f terraform: start FlattenGraph impl. 2015-04-30 20:46:54 -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
1152ff562b terraform: add variables as graph nodes (no eval yet) 2015-04-30 16:27:20 -07: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
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
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
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