terraform: Precondition and postcondition blocks generate dependencies

If a resource or output value has a precondition or postcondition rule
then anything the condition depends on is a dependency of the object,
because the condition rules will be evaluated as part of visiting the
relevant graph node.
This commit is contained in:
Martin Atkins 2020-11-20 15:10:08 -08:00 committed by Alisdair McDiarmid
parent 9076400436
commit c827c049fe
2 changed files with 14 additions and 1 deletions

View File

@ -237,8 +237,11 @@ func referencesForOutput(c *configs.Output) []*addrs.Reference {
refs := make([]*addrs.Reference, 0, l)
refs = append(refs, impRefs...)
refs = append(refs, expRefs...)
for _, check := range c.Preconditions {
checkRefs, _ := lang.ReferencesInExpr(check.Condition)
refs = append(refs, checkRefs...)
}
return refs
}
// GraphNodeReferencer

View File

@ -172,6 +172,16 @@ func (n *NodeAbstractResource) References() []*addrs.Reference {
result = append(result, refs...)
}
}
for _, check := range c.Preconditions {
refs, _ := lang.ReferencesInExpr(check.Condition)
result = append(result, refs...)
}
for _, check := range c.Postconditions {
refs, _ := lang.ReferencesInExpr(check.Condition)
result = append(result, refs...)
}
return result
}