Skip to content

Commit ccb5506

Browse files
committed
No longer ignores errors when deleting aws_datazone_project
1 parent 9886e05 commit ccb5506

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

internal/service/datazone/project.go

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ import (
3333
"github.com/hashicorp/terraform-provider-aws/internal/framework"
3434
"github.com/hashicorp/terraform-provider-aws/internal/framework/flex"
3535
fwtypes "github.com/hashicorp/terraform-provider-aws/internal/framework/types"
36+
tfslices "github.com/hashicorp/terraform-provider-aws/internal/slices"
3637
"github.com/hashicorp/terraform-provider-aws/internal/tfresource"
3738
"github.com/hashicorp/terraform-provider-aws/names"
3839
)
@@ -301,7 +302,7 @@ func (r *projectResource) Delete(ctx context.Context, req resource.DeleteRequest
301302
deleteTimeout := r.DeleteTimeout(ctx, state.Timeouts)
302303
_, err = waitProjectDeleted(ctx, conn, state.DomainIdentifier.ValueString(), state.ID.ValueString(), deleteTimeout)
303304

304-
if err != nil && !errs.IsA[*awstypes.AccessDeniedException](err) {
305+
if err != nil {
305306
resp.Diagnostics.AddError(
306307
create.ProblemStandardMessage(names.DataZone, create.ErrActionWaitingForDeletion, ResNameProject, state.ID.String(), err),
307308
err.Error(),
@@ -369,6 +370,14 @@ func statusProject(ctx context.Context, conn *datazone.Client, domain string, id
369370
return nil, "", err
370371
}
371372

373+
if len(out.FailureReasons) > 0 {
374+
if err := errors.Join(tfslices.ApplyToAll(out.FailureReasons, func(e awstypes.ProjectDeletionError) error {
375+
return errors.New(aws.ToString(e.Message))
376+
})...); err != nil {
377+
return nil, "", err
378+
}
379+
}
380+
372381
return out, string(out.ProjectStatus), nil
373382
}
374383
}
@@ -389,7 +398,7 @@ func findProjectByID(ctx context.Context, conn *datazone.Client, domain string,
389398
return nil, err
390399
}
391400

392-
if out == nil || !(out.FailureReasons == nil) {
401+
if out == nil {
393402
return nil, tfresource.NewEmptyResultError(in)
394403
}
395404

0 commit comments

Comments
 (0)