Merge pull request #9728 from hashicorp/b-prov-cycle
terraform: validate graph on resource expansation to catch cycles
This commit is contained in:
commit
144f31b6f2
|
@ -841,6 +841,27 @@ func TestContext2Plan_preventDestroy_destroyPlan(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestContext2Plan_provisionerCycle(t *testing.T) {
|
||||
m := testModule(t, "plan-provisioner-cycle")
|
||||
p := testProvider("aws")
|
||||
p.DiffFn = testDiffFn
|
||||
pr := testProvisioner()
|
||||
ctx := testContext2(t, &ContextOpts{
|
||||
Module: m,
|
||||
Providers: map[string]ResourceProviderFactory{
|
||||
"aws": testProviderFuncFixed(p),
|
||||
},
|
||||
Provisioners: map[string]ResourceProvisionerFactory{
|
||||
"local-exec": testProvisionerFuncFixed(pr),
|
||||
},
|
||||
})
|
||||
|
||||
_, err := ctx.Plan()
|
||||
if err == nil {
|
||||
t.Fatalf("should error")
|
||||
}
|
||||
}
|
||||
|
||||
func TestContext2Plan_computed(t *testing.T) {
|
||||
m := testModule(t, "plan-computed")
|
||||
p := testProvider("aws")
|
||||
|
|
|
@ -188,7 +188,7 @@ func (n *GraphNodeConfigResource) DynamicExpand(ctx EvalContext) (*Graph, error)
|
|||
steps = append(steps, &RootTransformer{})
|
||||
|
||||
// Build the graph
|
||||
b := &BasicGraphBuilder{Steps: steps}
|
||||
b := &BasicGraphBuilder{Steps: steps, Validate: true}
|
||||
return b.Build(ctx.Path())
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
resource "aws_instance" "foo" {
|
||||
count = 3
|
||||
|
||||
provisioner "local-exec" {
|
||||
command = "echo ${aws_instance.foo.0.id} ${aws_instance.foo.1.id} ${aws_instance.foo.2.id}"
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue