helper/resource: don't panic if a requested module does not exist

This commit is contained in:
Stuart Auld 2018-02-17 06:32:49 +11:00 committed by Martin Atkins
parent 10bb21e9c4
commit 7d1f594f54
1 changed files with 4 additions and 0 deletions

View File

@ -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)
}