diff --git a/google/resource_access_context_manager_access_level.go b/google/resource_access_context_manager_access_level.go index 83430a6fc47..fa2a4ff2ae9 100644 --- a/google/resource_access_context_manager_access_level.go +++ b/google/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/resource_access_context_manager_service_perimeter.go b/google/resource_access_context_manager_service_perimeter.go index 73b91f13e25..0575506ecec 100644 --- a/google/resource_access_context_manager_service_perimeter.go +++ b/google/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 }