Commit Graph

1577 Commits

Author SHA1 Message Date
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
Mitchell Hashimoto
8ef35d7561
terraform: simplify the shadow component factory
This unifies shadow/real under one since it was really just a basic
switch of what to return.
2016-10-11 22:17:29 +08:00
Mitchell Hashimoto
89e8656c6b
terraform: component uid includes the path 2016-10-11 22:17:29 +08:00
Mitchell Hashimoto
0b00bbde4e
terraform: switch to a component factory
This is necessary so that the shadow version can actually keep track of
what provider is used for what. Before, providers for different alises
were just initialized but the factory had no idea. Arguably this is fine
but when trying to build a shadow graph this presents challenges.

With these changes, we now pass an opaque "uid" through that is used to
keep track of the providers and what real maps to what shadow.
2016-10-11 22:17:29 +08:00
Mitchell Hashimoto
5053872e82
terraform: Diff.DeepCopy test to catch a bug that in copystructure
This was fixed upstream but keeping the test around to prevent
regressions.
2016-10-11 22:17:29 +08:00
Mitchell Hashimoto
742af8752b
terraform: run the shadow graph for Apply operations (everything fails) 2016-10-11 22:17:28 +08:00
Mitchell Hashimoto
02e93f5920
terraform: shadowResourceProviderFactory
This helper helps create the factory maps for the context.
2016-10-11 22:17:28 +08:00
Mitchell Hashimoto
f7134d95e4
terraform: Diff.DeepCopy 2016-10-11 22:17:28 +08:00
Mitchell Hashimoto
9ae9f208d1
terraform: Context knows how to walk a shadow graph and report errors 2016-10-11 22:17:28 +08:00
Mitchell Hashimoto
3504054b1e
terraform: EvalContext.CloseProvider (shadow) works if never init 2016-10-11 22:17:28 +08:00
Mitchell Hashimoto
17b909a59b
terraform: EvalContext.CloseProvider (shadow) 2016-10-11 22:17:28 +08:00
Mitchell Hashimoto
ea8e7659e2
terraform: EvalContext.Provider (shadow) 2016-10-11 22:17:28 +08:00
Mitchell Hashimoto
ce56712473
terraform: EvalContext.InitProvider(shadow) test double init 2016-10-11 22:17:28 +08:00
Mitchell Hashimoto
792a9f1de4
terraform: EvalContext.InitProvider (shadow) tests 2016-10-11 22:17:28 +08:00
Mitchell Hashimoto
fb96b0c422
terraform: EvalContext.initProvider shadow 2016-10-11 22:17:28 +08:00
Mitchell Hashimoto
51ac3c5969
terraform: ResourceProvider.Refresh (shadow) 2016-10-11 22:17:28 +08:00
Mitchell Hashimoto
82a1158f55
terraform: ResourceProvider.Diff shadow 2016-10-11 22:17:28 +08:00
Mitchell Hashimoto
cbbd492bce
terraform: shadow resource provider Apply 2016-10-11 22:17:27 +08:00
Mitchell Hashimoto
3522b07b75
terraform: Shadow resource provider Configure 2016-10-11 22:17:27 +08:00
Mitchell Hashimoto
23204d2414
terraform: ResourceProvider.Validate for shadow 2016-10-11 22:17:27 +08:00
Mitchell Hashimoto
bb5f116cec
terraform: shadow resource provider tests begin 2016-10-11 22:17:27 +08:00
Mitchell Hashimoto
d37bb87bf2
terraform: ResourceConfig.DeepCopy should handle the nil case 2016-10-11 22:17:27 +08:00
Mitchell Hashimoto
37f5c6ae26
terraform: ResourceConfig.Equal handles nil case 2016-10-11 22:17:27 +08:00
Mitchell Hashimoto
f73dc844c7
wip 2016-10-11 22:17:27 +08:00
Mitchell Hashimoto
1df3bbdc37
terraform: working on the resource provider shadow, not working yet 2016-10-11 22:17:27 +08:00
Mitchell Hashimoto
35f13f9c52
terraform: wip on shadow graph, compiles 2016-10-11 22:17:27 +08:00
Mitchell Hashimoto
8c9097f454
terraform: orphaned grandchild module inherits provider config
This fixes an issue where orphaned grandchild modules don't properly
inherit their provider configurations from grandparents. I found this
while working on shadow graphs (the shadow graph actually caught an
inconsistency between runs and exposed this bug!), so I'm unsure if this
affects any issue.

To better explain the issue, I'll diagram things.

Here is a hierarchy that _works_ (w/o this PR):

```
root
|-- child1 (orphan)
|-- child2
    |-- grandchild
```

All modules in this case will successfully inherit provider
configurations from "root".

Here is a hierarchy that _doesn't work without this PR_:

```
root
|-- child1 (orphan)
    |-- grandchild (orphan)
```

In this case, `child1` does successfully inherit the provider from root,
but `grandchild` _will not_ unless `child1` had resources. If `child1`
has no resources, it wouldn't inherit anything. This PR fixes that.
2016-10-11 15:51:27 +08:00
James Bardin
48c8afaa11 Check for multi-values maps in output too
A map value read from a config file will be the default
`[]map[string]interface{}` type decoded from HCL. Since this type can't
be applied to a variable, it's likely that it was a simple map. If
there's a single map value, we can pull that out of the slice during
Eval.
2016-10-07 15:09:03 -04:00
clint
3e3854ed65 release: clean up after v0.7.5 2016-10-06 17:57:23 +00:00
clint
f7fa785925
v0.7.5 2016-10-06 17:41:22 +00:00
James Bardin
828aa7cfb4 Merge pull request #9062 from hashicorp/jbardin/race-fix
Fix race on Provisioner.RawConfig
2016-10-04 12:23:31 -04:00
James Bardin
77a64e7cb3 Merge pull request #9079 from hashicorp/jbardin/json-map
Allow map variables from json
2016-10-04 12:22:57 -04:00
James Nugent
7dab27065f core: Log diff mismatch using spew instead of %#v
This commit improves the error logging for "Diffs do not match" errors
by using the go-spew library to ensure that the structures are presented
fully and in a consistent order. This allows use of the command line
diff tool to analyse what is wrong.
2016-09-29 14:45:46 -05:00
Mitchell Hashimoto
ea342b793b
Update reflectwalk vendor to fix State.DeepCopy
The real reasoning for this can be found in #9, #10, and #11. All
these vendor updates aim to fix that issue, with minor adjustments
2016-09-27 19:52:12 -07:00
Mitchell Hashimoto
f897fa4701
terraform: ResourceConfig.Equal and tests 2016-09-27 18:52:32 -07:00
Mitchell Hashimoto
56901e5cfd
terraform: ResourceConfig.DeepCopy
This implements DeepCopy, still need to implement Equals to make this
more useful. Coming in the next commit but this still has its own full
functionality + tests.
2016-09-27 16:09:32 -07:00
James Bardin
3297a460c7 Allow map variables from json
A JSON object will be decoded as a list with a single map value. This
will be properly coerced later, so let it through the initial config
semantic checks.
2016-09-27 13:29:14 -04:00
James Bardin
475e0f1e6b Fix race on Provisioner.RawConfig
A race when accessing Provisioner.RawConfig can cause unexpected output
for provisioners that interpolate variables. Use RawConfig.Copy which
needs to acquire the RawConfig mutex to get the values.

Fixes #8890
2016-09-26 14:34:05 -04:00
Martin Atkins
ab29eca045 core: don't force data resource id diff to be empty
In an attempt to always show "id" as computed we were producing a
synthetic diff for it, but this causes problems when the id attribute for
a particular data source is actually settable in configuration, since it
masks the setting from the config and forces it to always be empty.

Instead, we'll set it conditionally so that a value provided in the config
can shine through when available.
2016-09-24 12:48:58 -07:00
Kyle Havlovitz
3a2819de25 core: Fixed variables not being in scope for destroy -target on modules 2016-09-23 19:05:40 -04:00
James Bardin
e58c6cf7da release: clean up after v0.7.4 2016-09-19 19:37:54 +00:00
James Bardin
84592f5967
v0.7.4 2016-09-19 19:13:49 +00:00
James Bardin
e5ff4d5bd4 create some unlocked methods for State
State.Init() needs to be called externally, so make sure it only calls
unlocked internal methods once a lock is acquired.
2016-09-16 09:59:04 -04:00
James Bardin
90aab0105d Add locks to InstanceState
Rename receivers for consistency
2016-09-16 09:59:04 -04:00
James Bardin
8d5080fe72 Lock all ResourceState methods
Also rename receivers so they are consistent.
2016-09-16 09:59:04 -04:00
James Bardin
469e71a488 add locks to all exported ModuleState methods 2016-09-16 09:59:04 -04:00
James Bardin
f1b44e36b4 add lock to OutputState.Equal 2016-09-16 09:59:04 -04:00
James Bardin
1235623fad Add locks to exported RemoteState methods 2016-09-16 09:59:04 -04:00
James Bardin
0be90c8994 Add locks to all exported State methods
move implementation into private methods when needed
2016-09-16 09:59:04 -04:00
David Tolnay
61185f083c Merge branch hashicorp/master into dtolnay/conflict 2016-09-07 19:17:22 -07:00
Trevor Pounds
38784cd38f Cleanup inaccurate state structure comments. 2016-09-06 16:24:51 -04:00
stack72
cdcff09d99
release: clean up after v0.7.3 2016-09-05 13:11:19 +01:00
stack72
0dd7c657d6
v0.7.3 2016-09-05 12:01:12 +00:00
James Bardin
2623d84a41 Add a context test for a datasource with count 2016-09-03 13:08:41 -07:00
Sander van Harmelen
47dd1ad153 Add wildcard (match all) support to ignore_changes (#8599) 2016-09-02 15:44:35 +02:00
Mitchell Hashimoto
d081ad1bc0 Merge pull request #8581 from hashicorp/f-self-count
terraform: self.count works in interpolations [GH-5283]
2016-08-31 11:58:36 -07:00
Mitchell Hashimoto
60f212b73e
terraform: test for referencing counts that are from vars 2016-08-31 11:54:14 -07:00
Mitchell Hashimoto
d2e15ab69a
terraform: add test explicitly for referencing count 2016-08-31 11:49:25 -07:00
Mitchell Hashimoto
08a9c8e2c2
terraform: self.count works in interpolations [GH-5283] 2016-08-31 11:36:51 -07:00
James Bardin
632c16c212 Fix inconsistent results with self interpolation
Due to a race in interpolateForce(), a reference to self could return
inconsistent results.
2016-08-30 14:16:37 -04:00
Mitchell Hashimoto
3c2db3d572 Merge pull request #8463 from hashicorp/b-read-state-validate
Validate the state on load
2016-08-26 13:27:21 -07:00
James Bardin
f326dad2ba Merge pull request #8452 from hashicorp/jbardin/locked-copy
Add locks to state structs for copying
2016-08-25 17:06:20 -04:00
James Bardin
4559eec8be Remove the proposed LockedCopy function
We didn't add the LockedCopy function in copystructure, in favor of
using the Config struct directly.
2016-08-25 16:55:28 -04:00
James Bardin
0e6e206465 Add an InstanceState.Set method to set all fields
We con no longer copy an InstanceState via a simple
dereference+assignment because of the mutex which can't be copied. This
adds a set method to properly set all field from another InstanceState,
and take the appropriate locks while doing so.
2016-08-25 14:41:51 -04:00
James Bardin
2a47b32374 fix State.Add chart so it renders in godoc 2016-08-25 14:41:51 -04:00
James Bardin
7a579c271d Remove GoString methods from state
These method set the GoString format behavior, but they only output the
default GoString format. Remove them to prevent copying mutex values.
2016-08-25 14:41:39 -04:00
stack72
5861802d08 release: clean up after v0.7.2 2016-08-25 15:11:50 +00:00
stack72
0985f39e99
v0.7.2 2016-08-25 14:29:18 +00:00
Mitchell Hashimoto
73f7c04159
terraform: clear docs for devs 2016-08-24 18:44:54 -07:00
Mitchell Hashimoto
3376611ad0
terraform: Validate validates single module states 2016-08-24 18:42:13 -07:00
Mitchell Hashimoto
c65bbc4f0c
terraform: minor edits to reading state to prep for validation 2016-08-24 18:20:47 -07:00
James Bardin
056fd70da4 Add locks to state structs for copying
Add locks to the state structs to handle concurrency during the graph
walks. We can't embed the mutexes due to serialization constraints when
communicating with providers, so expose the Lock/Unlock methods
manually.

Use copystructure.LockedCopy to ensure locks are honored.
2016-08-24 11:15:52 -04:00
Mitchell Hashimoto
b9219103df
terraform: prefix destroy resources with module path [GH-2767] 2016-08-22 13:33:11 -07:00
Mitchell Hashimoto
f98459d683 Merge pull request #8304 from hashicorp/b-state-mv
Fix `state mv` with nested modules to work properly
2016-08-20 00:00:22 -04:00
Mitchell Hashimoto
c22ab252dd
terraform: import specific index works [GH-7691] 2016-08-19 19:14:33 -04:00
clint
146da09d5d release: clean up after v0.7.1 2016-08-19 20:28:17 +00:00
clint
55ba6ebd3d
v0.7.1 2016-08-19 19:58:17 +00:00
Mitchell Hashimoto
8afbb0ee0e
terraform: state mv "foo" to "foo.0" with single count 2016-08-19 11:54:53 -04:00
Mitchell Hashimoto
88649ed010
terraform: StateAdd edge case test for multi-count to single index 2016-08-19 11:51:31 -04:00
Mitchell Hashimoto
a22f7e8257
terraform: State.Add works with multiple resources [GH-7797] 2016-08-19 11:46:52 -04:00
Mitchell Hashimoto
4454d534fc
terraform: test for querying count resources 2016-08-19 11:41:00 -04:00
Mitchell Hashimoto
3b3f92cd9b
terraform: fix some test failures on state add with multiple modules 2016-08-18 17:39:07 -04:00
Mitchell Hashimoto
3892cc4e91
terraform: fix state add with multiple ModuleStates 2016-08-18 17:13:53 -04:00
Mitchell Hashimoto
a44c8b8760
terraform: state mv tests 2016-08-18 15:05:42 -04:00
Mitchell Hashimoto
05cbb5c0ea
terraform: add test for filtering nested modules 2016-08-17 18:54:47 -05:00
Mitchell Hashimoto
802de4ea28
terraform: fix vet 2016-08-17 12:03:21 -07:00
Mitchell Hashimoto
cc5abd0815
terraform: add tests for variables 2016-08-17 11:28:58 -07:00
Mitchell Hashimoto
af7085f671
terraform: refactor var loading out to a helper
Small style changes too
2016-08-17 11:10:26 -07:00
Mitchell Hashimoto
e6d1e77a9a
Fix vet errors found with Go 1.7 2016-08-16 18:03:22 -07:00
Mitchell Hashimoto
f4faf2274b
config: count can't be a SimpleVariable 2016-08-16 13:48:12 -07:00
James Nugent
f933b2cf16 Merge pull request #8200 from hashicorp/fix-state-rm
core: Add `terraform state rm` command
2016-08-16 19:10:17 +01:00
Paul Hinze
50df583ffd Merge pull request #8120 from hashicorp/jbardin/null-state-module
Fix panic from a null resources module in a state file
2016-08-16 09:45:52 -05:00
Mitchell Hashimoto
0a2fd1a5e5 terraform: filtering on name actually matches name 2016-08-15 14:36:23 -05:00
Paul Hinze
b9f950f1d4 Merge pull request #8167 from hashicorp/b-tainted-no-attrs-still-replaces
terraform: diffs with only tainted set are non-empty
2016-08-12 18:06:32 -05:00
Paul Hinze
3dccfa0cc9
terraform: diffs with only tainted set are non-empty
Fixes issue where a resource marked as tainted with no other attribute
diffs would never show up in the plan or apply as needing to be
replaced.

One unrelated test needed updating due to a quirk in the testDiffFn
logic - it adds a "type" field diff if the diff is non-Empty. NBD
2016-08-12 17:37:49 -05:00
James Bardin
cdb80f68a8 Ensure better state normalization
Fix checksum issue with remote state

If we read a state file with "null" objects in a module and they become
initialized to an empty map the state file may be written out with empty
objects rather than "null", changing the checksum. If we can detect
this, increment the serial number to prevent a conflict in atlas.

Our fakeAtlas test server now needs to decode the state directly rather
than using the ReadState function, so as to be able to read the state
unaltered.

The terraform.State data structures have initialization spread out
throughout the package. More thoroughly initialize State during
ReadState, and add a call to init() during WriteState as another
normalization safeguard.

Expose State.init through an exported Init() method, so that a new State
can be completely realized outside of the terraform package.
Additionally, the internal init now completely walks all internal state
structures ensuring that all maps and slices are initialized.  While it
was mentioned before that the `init()` methods are problematic with too
many call sites, expanding this out better exposes the entry points that
will need to be refactored later for improved concurrency handling.

The State structures had a mix of `omitempty` fields. Remove omitempty
for all maps and slices as part of this normalization process. Make
Lineage mandatory, which is now explicitly set in some tests.
2016-08-12 11:09:50 -04:00
James Bardin
c48a1423a1 Collapse nested if with an && 2016-08-10 16:34:21 -04:00
James Bardin
d6c8b40201 unify some of the test code
Have all the values in the testDiffFn go through the same code path
2016-08-10 11:37:55 -04:00
James Bardin
2e5791ab2b Allow the HCL input when prompted
We already accept HCL encoded input for -vars, and this expands that to
accept HCL when prompted for a value on the command line as well.
2016-08-10 11:14:31 -04:00
James Nugent
fa64ac7815 release: clean up after v0.7.0 2016-08-02 18:17:05 +00:00
James Nugent
e822a79165
v0.7.0 2016-08-02 17:59:44 +00:00
James Bardin
1af7ee87a2 Silence log output when not verbose
Set the default log package output to iotuil.Discard during tests if the
`-v` flag isn't set. If we are verbose, then apply the filter according
to the TF_LOG env variable.
2016-08-01 17:19:14 -04:00
Paul Stack
2e38467213 release: clean up after v0.7.0-rc4 2016-07-30 00:53:38 +00:00
Paul Stack
abfd2c1daf
v0.7.0-rc4 2016-07-29 23:40:54 +00:00
James Bardin
2747d964cb Merge pull request #7877 from hashicorp/jbardin/races
core: Fix race conditions, mostly around diffs
2016-07-29 18:42:31 -04:00
Paul Hinze
46b78286bc Merge pull request #7865 from hashicorp/b-filter-untargeted-variables
terraform: Filter untargeted variable nodes
2016-07-29 17:08:08 -05:00
Paul Hinze
24c45fcd5d
terraform: Filter untargeted variable nodes
When targeting, only Addressable untargeted nodes were being removed
from the graph. Variable nodes are not directly Addressable, so they
were hanging around. This caused problems with module variables that
referred to Resource nodes. The Resource node would be filtered out of
the graph, but the module Variable node would not, so it would try to
interpolate during the graph walk and be unable to find it's referent.

This would present itself as strange "cannot find variable" errors for
variables that were uninvolved with the currently targeted set of
resources.

Here, we introduce a new interface that can be implemented by graph
nodes to indicate they should be filtered out from targeting even though
they are not directly addressable themselves.
2016-07-29 16:55:30 -05:00
James Nugent
9034196baf Merge pull request #7875 from hashicorp/b-outputs-by-module
core: Fix -module for terraform output command
2016-07-29 16:40:24 -05:00
James Nugent
0e4e94a86f core: Fix -module for terraform output command
The behaviour whereby outputs for a particular nested module can be
output was broken by the changes for lists and maps. This commit
restores the previous behaviour by passing the module path into the
outputsAsString function.

We also add a new test of this since the code path for indivdual output
vs all outputs for a module has diverged.
2016-07-29 16:39:59 -05:00
James Bardin
5802f76eaa Make all terraform package tests pass under -race
This isn't a pretty refactor, but fixes the race issues in this package
for now.

Fix race on RawConfig.Config()

fix command package races
2016-07-29 16:12:21 -04:00
Clint
a9aaf44a87 fix make issues (supersedes #7868) (#7876)
* Fixing the make error or invalid data type for errorf and printf

* fix make errors
2016-07-29 21:05:57 +01:00
Matt Morrison
dbf04721d2 Tainted resource not recreated if ignore_changes used on any attributes. 2016-07-29 09:12:39 +12:00
James Bardin
9dec28bccf Merge pull request #7803 from hashicorp/jbardin/tf_vars-push
Add tf_vars to the variables sent in push
2016-07-28 16:31:04 -04:00
James Bardin
341abd7956 limit input retries
Prevent going into a busy loop if the input fd closes early.
2016-07-28 08:49:09 -04:00
James Nugent
7af10adcbe core: Do not assume HCL parser has touched vars
This PR fixes #7824, which crashed when applying a plan file. The bug is
that while a map which has come from the HCL parser reifies as a
[]map[string]interface{}, the variable saved in the plan file was not.
We now cover both cases.

Fixes #7824.
2016-07-27 17:14:47 -05:00
James Nugent
681d94ae20 core: Allow lists and maps as variable overrides
Terraform 0.7 introduces lists and maps as first-class values for
variables, in addition to string values which were previously available.
However, there was previously no way to override the default value of a
list or map, and the functionality for overriding specific map keys was
broken.

Using the environment variable method for setting variable values, there
was previously no way to give a variable a value of a list or map. These
now support HCL for individual values - specifying:

    TF_VAR_test='["Hello", "World"]'

will set the variable `test` to a two-element list containing "Hello"
and "World". Specifying

    TF_VAR_test_map='{"Hello = "World", "Foo" = "bar"}'

will set the variable `test_map` to a two-element map with keys "Hello"
and "Foo", and values "World" and "bar" respectively.

The same logic is applied to `-var` flags, and the file parsed by
`-var-files` ("autoVariables").

Note that care must be taken to not run into shell expansion for `-var-`
flags and environment variables.

We also merge map keys where appropriate. The override syntax has
changed (to be noted in CHANGELOG as a breaking change), so several
tests needed their syntax updating from the old `amis.us-east-1 =
"newValue"` style to `amis = "{ "us-east-1" = "newValue"}"` style as
defined in TF-002.

In order to continue supporting the `-var "foo=bar"` type of variable
flag (which is not valid HCL), a special case error is checked after HCL
parsing fails, and the old code path runs instead.
2016-07-26 15:27:29 -05:00
James Bardin
f66d1a10a4 Add VersionString
We conditionally format version with VersionPrerelease in a number of
places. Add a package-level function where we can unify the version
format. Replace most of version formatting in terraform, but leave th
few instances set from the top-level package to make sure we don't break
anything before release.
2016-07-21 16:43:49 -04:00
James Bardin
885935962c Add a terraform version header to all atlas calls
Using the DefaultHeader added to the atlas.Client
2016-07-21 11:04:27 -04:00
James Bardin
87a5ce8045 Add tests for maps with dots
This adds some unit tests for config maps with dots in the key values.
We check for maps with keys which have overlapping names. There are
however still issues with nested maps which create overlapping flattened
names, as well as nested lists with dots in the key.
2016-07-20 14:08:14 -04:00
James Nugent
5d18f41f04 core: Convert context vars to map[string]interface{}
This is the first step in allowing overrides of map and list variables.
We convert Context.variables to map[string]interface{} from
map[string]string and fix up all the call sites.
2016-07-18 13:02:54 -05:00
Paul Hinze
7c40c174ef
clean up after v0.7.0-rc3 2016-07-15 18:33:02 -06:00
Paul Hinze
3f4857a07a
v0.7.0-rc3 2016-07-15 22:29:21 +00:00
Paul Hinze
b45f53eef4
dag: fix ReverseDepthFirstWalk when nodes remove themselves
The report in #7378 led us into a deep rabbit hole that turned out to
expose a bug in the graph walk implementation being used by the
`NoopTransformer`. The problem ended up being when two nodes in a single
dependency chain both reported `Noop() -> true` and needed to be
removed. This was breaking the walk and preventing the second node from
ever being visited.

Fixes #7378
2016-07-15 13:43:28 -06:00
Paul Hinze
9fe916248c Merge pull request #7654 from hashicorp/zeroae-b-triton-dot-in-tags
Support "." in map keys
2016-07-15 09:48:19 -06:00
James Nugent
340655d56c core: Allow "." character in map keys
Fixes #2143 and fixes #7130.
2016-07-14 12:38:43 -06:00
James Nugent
56aadab115 core: Add context test for module var from splat
This adds additional coverage of the situation reported in #7195 to
prevent against regression. The actual fix was in 2356afd, in response
to #7143.
2016-07-13 11:23:56 -06:00
James Nugent
788bff46e2 Merge pull request #7563 from hashicorp/b-ignore-changes-dependency
terraform: another set of ignore_changes fixes
2016-07-13 11:06:49 -06:00
James Nugent
d955c5191c core: Fix interpolation tests with nested lists
Some of the tests for splat syntax were from the pre-list-and-map world,
and effectively flattened the values if interpolating a resource value
which was itself a list.

We now set the expected values correctly so that an interpolation like
`aws_instance.test.*.security_group_ids` now returns a list of lists.

We also fix the implementation to correctly deal with maps.
2016-07-11 17:02:12 -06:00
Paul Hinze
14cea95e86
terraform: another set of ignore_changes fixes
This set of changes addresses two bug scenarios:

(1) When an ignored change canceled a resource replacement, any
downstream resources referencing computer attributes on that resource
would get "diffs didn't match" errors. This happened because the
`EvalDiff` implementation was calling `state.MergeDiff(diff)` on the
unfiltered diff. Generally this is what you want, so that downstream
references catch the "incoming" values. When there's a potential for the
diff to change, thought, this results in problems w/ references.

Here we solve this by doing away with the separate `EvalNode` for
`ignore_changes` processing and integrating it into `EvalDiff`. This
allows us to only call `MergeDiff` with the final, filtered diff.

(2) When a resource had an ignored change but was still being replaced
anyways, the diff was being improperly filtered. This would cause
problems during apply when not all attributes were available to perform
the replacement.

We solve that by deferring actual attribute removal until after we've
decided that we do not have to replace the resource.
2016-07-08 16:48:23 -05:00
James Nugent
b6fff854a6 core: Set all unknown keys to UnknownVariableValue
As part of evaluating a variable block, there is a pass made on unknown
keys setting them to the config.DefaultVariableValue sentinal value.
Previously this only took into account one level of nesting and assumed
all values were strings.

This commit now traverses the unknown keys via lists and maps and sets
unknown map keys surgically.

Fixes #7241.
2016-07-08 16:44:40 +01:00
James Nugent
088feb933f terraform: Add test case reproducing #7241
The reproduction of issue #7421 involves a list of maps being passed to
a module, where one or more of the maps has a value which is computed
(for example, from another resource). There is a failure at the point of
use (via lookup interpolation) of the computed value of the form:

```
lookup: lookup failed to find 'elb' in:
${lookup(var.services[count.index], "elb")}
```

Where 'elb' is the key of the map.
2016-07-08 16:43:42 +01:00
James Nugent
1401a52a5c Merge pull request #7493 from hashicorp/b-pass-map-to-module
terraform: allow literal maps to be passed to modules
2016-07-08 11:50:29 +01:00
James Bardin
21e2173e0a Fix nested module "unknown variable" during dest (#7496)
* Fix nested module "unknown variable" during dstry

During a destroy with nested modules, accessing a variable between them
causes an "unknown variable accessed" during destroy.
2016-07-06 11:22:41 -04:00
Paul Hinze
559f14c3fa
terraform: allow literal maps to be passed to modules
Passing a literal map to a module looks like this in HCL:

    module "foo" {
      source = "./foo"
      somemap {
        somekey = "somevalue"
      }
    }

The HCL parser always wraps an extra list around the map, so we need to
remove that extra list wrapper when the parameter is indeed of type "map".

Fixes #7140
2016-07-06 09:52:32 -05:00
Paul Hinze
1a4bd24e1a
terraform: add test helper for inline config loading
In scenarios with a lot of small configs, it's tedious to fan out actual
dir trees in a test-fixtures dir. It also spreads out the context of the
test - requiring the reader fetch a bunch of scattered 3 line files in
order to understand what is being tested.

Our config loading code still only reads from disk, but in
the `helper/resource` acc test framework we work around this by writing
inline config to temp files and loading it from there. This helper is
based on that strategy.

Eventually it'd be great to be able to build up a `module.Tree` from
config directly, but this gets us the functionality today.

Example Usage:

    testModuleInline(t, map[string]string{
      "top.tf": `
        module "middle" {
          source = "./middle"
        }
      `,
      "middle/mid.tf": `
        module "bottom" {
          source = "./bottom"
          amap {
            foo = "bar"
          }
        }
      `,
      "middle/bottom/bot.tf": `
        variable "amap" {
          type = "map"
        }
      `,
    }),
2016-07-06 09:12:19 -05:00
Paul Hinze
4a1b36ac0d
core: rerun resource validation before plan and apply
In #7170 we found two scenarios where the type checking done during the
`context.Validate()` graph walk was circumvented, and the subsequent
assumption of type safety in the provider's `Diff()` implementation
caused panics.

Both scenarios have to do with interpolations that reference Computed
values. The sentinel we use to indicate that a value is Computed does
not carry any type information with it yet.

That means that an incorrect reference to a list or a map in a string
attribute can "sneak through" validation only to crop up...

 1. ...during Plan for Data Source References
 2. ...during Apply for Resource references

In order to address this, we:

 * add high-level tests for each of these two scenarios in `provider/test`
 * add context-level tests for the same two scenarios in `terraform`
   (these tests proved _really_ tricky to write!)
 * place an `EvalValidateResource` just before `EvalDiff` and `EvalApply` to
   catch these errors
 * add some plumbing to `Plan()` and `Apply()` to return validation
   errors, which were previously only generated during `Validate()`
 * wrap unit-tests around `EvalValidateResource`
 * add an `IgnoreWarnings` option to `EvalValidateResource` to prevent
   active warnings from halting execution on the second-pass validation

Eventually, we might be able to attach type information to Computed
values, which would allow for these errors to be caught earlier. For
now, this solution keeps us safe from panics and raises the proper
errors to the user.

Fixes #7170
2016-07-01 13:12:57 -05:00
Paul Hinze
40fbb8d2e8 Merge pull request #7370 from tpounds/show-tf-ver-on-state-mismatch
Show Terraform version on state version mismatch.
2016-06-29 10:48:13 -05:00
James Bardin
68010599b1 Merge pull request #7403 from hashicorp/jbardin/GH-7394
core: Don't set Modules to nil during state upgrade
2016-06-29 10:05:57 -04:00
James Bardin
1b75c51ed7 Don't nil module maps during state upgrade
The Outputs and Resources maps in the state modules are expected to be
non-nil, and initialized that way when a new module is added to the
state.  The V1->V2 upgrade was setting the maps to nil if the len == 0.
2016-06-29 09:17:25 -04:00
James Bardin
94f1899f4e increment the state serial whenever we upgrade
Always increment the state serial whenever we upgrade the state version.
This prevents possible version conflicts between local and remote state
when one has been upgraded, but the serial numbers match.
2016-06-28 16:32:36 -04:00
Trevor Pounds
c4423bba17 Fix state version error message check. 2016-06-27 13:42:44 -07:00
Trevor Pounds
5932214f0d Show Terraform version on state version mismatch. 2016-06-27 11:52:43 -07:00
James Bardin
0e507e7e5e Remove computed maps from the diff Same check
Just like computed sets, computed maps may have both different values
and different cardinality after they're computed. Remove the computed
maps and the values from the compared diffs.
2016-06-27 10:04:45 -04:00
David Tolnay
ff80e7b245
Allow refresh of local state with no resources 2016-06-24 21:54:43 -07:00
James Nugent
1f9a2b241e Merge pull request #7207 from hashicorp/b-diff-maps
core/diff: Fix attribute mismatch with tags.%
2016-06-24 15:03:36 +03:00
James Nugent
cd354ed3c7 core: Use Terraform terms over HCL ones 2016-06-24 12:42:39 +01:00
James Bardin
416e875bff Output expected HCL types when evaluating config
Don't refer to Go types when an unexpected type is encountered in the
config.
2016-06-24 12:42:01 +01:00
James Nugent
2356afde84 core: Fix interpolation of unknown multi-variables
This commit test "TestContext2Input_moduleComputedOutputElement"
by ensuring that we treat a count of zero and non-reified resources
independently rather than returning an empty list for both, which
results in an interpolation failure when using the element function or
indexing.
2016-06-23 21:15:33 +01:00
James Nugent
983e4f13c6 core: Add context test for empty lists as module outputs
This test illustrates a failure which occurs during the Input walk, if
an interpolation is used with the input of a splat operation resulting
in a multi-variable.

The bug was found during use of the RC2, but does not correspond to an
open issue at present.
2016-06-23 21:15:33 +01:00
James Nugent
17f4777039 core: Fix Stringer on OutputState for types
The implementation of Stringer on OutputState previously assumed outputs
may only be strings - we now no longer cast to string, instead using the
built in formatting directives.
2016-06-23 21:15:33 +01:00