diff --git a/helper/resource/testing.go b/helper/resource/testing.go index 1430bb8d2..27bfc9b5a 100644 --- a/helper/resource/testing.go +++ b/helper/resource/testing.go @@ -1144,6 +1144,10 @@ func modulePrimaryInstanceState(s *terraform.State, ms *terraform.ModuleState, n // given resource name in a given module path. func modulePathPrimaryInstanceState(s *terraform.State, mp []string, name string) (*terraform.InstanceState, error) { ms := s.ModuleByPath(mp) + if ms == nil { + return nil, fmt.Errorf("No module found at: %s", mp) + } + return modulePrimaryInstanceState(s, ms, name) }