From 7d1f594f54ab741ff021b82b94d73d7dc2fb8651 Mon Sep 17 00:00:00 2001 From: Stuart Auld Date: Sat, 17 Feb 2018 06:32:49 +1100 Subject: [PATCH] helper/resource: don't panic if a requested module does not exist --- helper/resource/testing.go | 4 ++++ 1 file changed, 4 insertions(+) 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) }