instances: Fix data race in Expander.ExpandAbsModuleCall

This method must hold a read lock while it does its work, or else it will
race with calls to register the expansion mode for other module calls.
improve-dynamic-block-error-message
Martin Atkins 2 years ago
parent e6ce1edf22
commit 73df33fe6e

@ -154,6 +154,9 @@ func (e *Expander) ExpandModule(addr addrs.Module) []addrs.ModuleInstance {
// key type: integer keys are sorted numerically, and string keys are sorted
// lexically.
func (e *Expander) ExpandAbsModuleCall(addr addrs.AbsModuleCall) (keyType addrs.InstanceKeyType, insts []addrs.InstanceKey, known bool) {
e.mu.RLock()
defer e.mu.RUnlock()
expParent, ok := e.findModule(addr.Module)
if !ok {
// This module call lives under an unknown-expansion prefix, so we

Loading…
Cancel
Save