connect references to the resource type

References can't be connected directly to the instances, because the
resources are expanded when ReferenceTransformer is run. Lookup
references by the resource type.
This commit is contained in:
James Bardin 2018-05-25 09:07:07 -04:00 committed by Martin Atkins
parent b979053361
commit 6ed1a81831
1 changed files with 10 additions and 1 deletions

View File

@ -202,7 +202,16 @@ func (m *ReferenceMap) References(v dag.Vertex) ([]dag.Vertex, []addrs.Reference
var missing []addrs.Referenceable var missing []addrs.Referenceable
for _, ref := range rn.References() { for _, ref := range rn.References() {
key := m.referenceMapKey(v, ref.Subject) subject := ref.Subject
// References may point to specific instances, but the resources may
// not yet be expanded. Make sure we reference the resource type
// itself.
if ri, ok := subject.(addrs.ResourceInstance); ok {
subject = ri.Resource
}
key := m.referenceMapKey(v, subject)
vertices := m.vertices[key] vertices := m.vertices[key]
for _, rv := range vertices { for _, rv := range vertices {
// don't include self-references // don't include self-references