Merge pull request #2555 from hashicorp/b-target-after-flatten

core: move targets transform after flatten
This commit is contained in:
Paul Hinze 2015-06-29 13:34:52 -05:00
commit 6bbf61ae6e
4 changed files with 58 additions and 4 deletions

View File

@ -6624,6 +6624,48 @@ module.child:
`)
}
// GH-1858
func TestContext2Apply_targetedModuleDep(t *testing.T) {
m := testModule(t, "apply-targeted-module-dep")
p := testProvider("aws")
p.ApplyFn = testApplyFn
p.DiffFn = testDiffFn
ctx := testContext2(t, &ContextOpts{
Module: m,
Providers: map[string]ResourceProviderFactory{
"aws": testProviderFuncFixed(p),
},
Targets: []string{"aws_instance.foo"},
})
if _, err := ctx.Plan(); err != nil {
t.Fatalf("err: %s", err)
}
state, err := ctx.Apply()
if err != nil {
t.Fatalf("err: %s", err)
}
checkStateString(t, state, `
aws_instance.foo:
ID = foo
foo = foo
type = aws_instance
Dependencies:
module.child
module.child:
aws_instance.mod:
ID = foo
Outputs:
output = foo
`)
}
func TestContext2Apply_targetedModuleResource(t *testing.T) {
m := testModule(t, "apply-targeted-module-resource")
p := testProvider("aws")

View File

@ -138,10 +138,6 @@ func (b *BuiltinGraphBuilder) Steps(path []string) []GraphTransformer {
// Make sure all the connections that are proxies are connected through
&ProxyTransformer{},
// Optionally reduces the graph to a user-specified list of targets and
// their dependencies.
&TargetsTransformer{Targets: b.Targets, Destroy: b.Destroy},
// Make sure we have a single root
&RootTransformer{},
}
@ -150,6 +146,10 @@ func (b *BuiltinGraphBuilder) Steps(path []string) []GraphTransformer {
// We don't do the following for modules.
if len(path) <= 1 {
steps = append(steps,
// Optionally reduces the graph to a user-specified list of targets and
// their dependencies.
&TargetsTransformer{Targets: b.Targets, Destroy: b.Destroy},
// Prune the providers and provisioners. This must happen
// only once because flattened modules might depend on empty
// providers.

View File

@ -0,0 +1,5 @@
resource "aws_instance" "mod" { }
output "output" {
value = "${aws_instance.mod.id}"
}

View File

@ -0,0 +1,7 @@
module "child" {
source = "./child"
}
resource "aws_instance" "foo" {
foo = "${module.child.output}"
}