terraform: dependencies in the graph from count properly show up
This commit is contained in:
parent
fa05b165ad
commit
039531e9ca
|
@ -1046,8 +1046,12 @@ func graphAddVariableDeps(g *depgraph.Graph) {
|
||||||
|
|
||||||
case *GraphNodeResource:
|
case *GraphNodeResource:
|
||||||
if m.Config != nil {
|
if m.Config != nil {
|
||||||
|
// Handle the count variables
|
||||||
|
vars := m.Config.RawCount.Variables
|
||||||
|
nounAddVariableDeps(g, n, vars, false)
|
||||||
|
|
||||||
// Handle the resource variables
|
// Handle the resource variables
|
||||||
vars := m.Config.RawConfig.Variables
|
vars = m.Config.RawConfig.Variables
|
||||||
nounAddVariableDeps(g, n, vars, false)
|
nounAddVariableDeps(g, n, vars, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -43,6 +43,21 @@ func TestGraph_count(t *testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestGraph_varResource(t *testing.T) {
|
||||||
|
m := testModule(t, "graph-count-var-resource")
|
||||||
|
|
||||||
|
g, err := Graph(&GraphOpts{Module: m})
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("err: %s", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
actual := strings.TrimSpace(g.String())
|
||||||
|
expected := strings.TrimSpace(testTerraformGraphCountVarResourceStr)
|
||||||
|
if actual != expected {
|
||||||
|
t.Fatalf("bad:\n\n%s", actual)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func TestGraph_cycle(t *testing.T) {
|
func TestGraph_cycle(t *testing.T) {
|
||||||
m := testModule(t, "graph-cycle")
|
m := testModule(t, "graph-cycle")
|
||||||
|
|
||||||
|
@ -964,6 +979,19 @@ root
|
||||||
root -> aws_load_balancer.weblb
|
root -> aws_load_balancer.weblb
|
||||||
`
|
`
|
||||||
|
|
||||||
|
const testTerraformGraphCountVarResourceStr = `
|
||||||
|
root: root
|
||||||
|
aws_instance.foo
|
||||||
|
aws_instance.web
|
||||||
|
aws_instance.web -> aws_instance.foo
|
||||||
|
aws_load_balancer.weblb
|
||||||
|
aws_load_balancer.weblb -> aws_instance.web
|
||||||
|
root
|
||||||
|
root -> aws_instance.foo
|
||||||
|
root -> aws_instance.web
|
||||||
|
root -> aws_load_balancer.weblb
|
||||||
|
`
|
||||||
|
|
||||||
const testTerraformGraphDependsStr = `
|
const testTerraformGraphDependsStr = `
|
||||||
root: root
|
root: root
|
||||||
aws_instance.db
|
aws_instance.db
|
||||||
|
|
|
@ -0,0 +1,9 @@
|
||||||
|
resource "aws_instance" "foo" {}
|
||||||
|
|
||||||
|
resource "aws_instance" "web" {
|
||||||
|
count = "${aws_instance.foo.bar}"
|
||||||
|
}
|
||||||
|
|
||||||
|
resource "aws_load_balancer" "weblb" {
|
||||||
|
members = "${aws_instance.web.*.id}"
|
||||||
|
}
|
Loading…
Reference in New Issue