diff --git a/internal/provider/resource_project_ownership.go b/internal/provider/resource_project_ownership.go index 098a8ae4f..3eb2aac24 100644 --- a/internal/provider/resource_project_ownership.go +++ b/internal/provider/resource_project_ownership.go @@ -225,5 +225,5 @@ func (r *ProjectOwnershipResource) Delete(ctx context.Context, req resource.Dele } func (r *ProjectOwnershipResource) ImportState(ctx context.Context, req resource.ImportStateRequest, resp *resource.ImportStateResponse) { - tfutils.ImportStateThreePartId(ctx, "organization", "project", req, resp) + tfutils.ImportStateTwoPart(ctx, "organization", "project", req, resp) } diff --git a/internal/tfutils/import_state.go b/internal/tfutils/import_state.go index bbc300f5a..86528991d 100644 --- a/internal/tfutils/import_state.go +++ b/internal/tfutils/import_state.go @@ -40,3 +40,13 @@ func ImportStateFourPartId(ctx context.Context, part1 string, part2 string, part resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root(part3), part3Value)...) resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("id"), id)...) } + +func ImportStateTwoPart(ctx context.Context, part1 string, part2 string, req resource.ImportStateRequest, resp *resource.ImportStateResponse) { + part1Value, part2Value, err := SplitTwoPartId(req.ID, part1, part2) + if err != nil { + resp.Diagnostics.Append(diagutils.NewImportError(err)) + return + } + resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root(part1), part1Value)...) + resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root(part2), part2Value)...) +}