diff --git a/google-beta/resource_access_context_manager_access_level.go b/google-beta/resource_access_context_manager_access_level.go index 83430a6fc4..fa2a4ff2ae 100644 --- a/google-beta/resource_access_context_manager_access_level.go +++ b/google-beta/resource_access_context_manager_access_level.go @@ -365,6 +365,9 @@ func resourceAccessContextManagerAccessLevelImport(d *schema.ResourceData, meta return nil, err } stringParts := strings.Split(d.Get("name").(string), "/") + if len(stringParts) < 2 { + return nil, fmt.Errorf("Error parsing parent name. Should be in form accessPolicies/{{policy_id}}/accessLevels/{{short_name}}") + } d.Set("parent", fmt.Sprintf("%s/%s", stringParts[0], stringParts[1])) return []*schema.ResourceData{d}, nil } diff --git a/google-beta/resource_access_context_manager_service_perimeter.go b/google-beta/resource_access_context_manager_service_perimeter.go index 73b91f13e2..0575506ece 100644 --- a/google-beta/resource_access_context_manager_service_perimeter.go +++ b/google-beta/resource_access_context_manager_service_perimeter.go @@ -332,6 +332,9 @@ func resourceAccessContextManagerServicePerimeterImport(d *schema.ResourceData, return nil, err } stringParts := strings.Split(d.Get("name").(string), "/") + if len(stringParts) < 2 { + return nil, fmt.Errorf("Error parsing parent name. Should be in form accessPolicies/{{policy_id}}/servicePerimeters/{{short_name}}") + } d.Set("parent", fmt.Sprintf("%s/%s", stringParts[0], stringParts[1])) return []*schema.ResourceData{d}, nil }