Skip to content

Commit eefb939

Browse files
committed
ECS Express: Retry deletion when service is draining
1 parent 906987a commit eefb939

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

internal/service/ecs/express_gateway_service.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -453,7 +453,8 @@ func (r *resourceExpressGatewayService) Read(ctx context.Context, req resource.R
453453
return
454454
}
455455

456-
if out.Status != nil && out.Status.StatusCode == awstypes.ExpressGatewayServiceStatusCodeInactive {
456+
if out.Status != nil && (out.Status.StatusCode == awstypes.ExpressGatewayServiceStatusCodeInactive ||
457+
out.Status.StatusCode == awstypes.ExpressGatewayServiceStatusCodeDraining) {
457458
resp.State.RemoveResource(ctx)
458459
return
459460
}
@@ -641,6 +642,11 @@ func (r *resourceExpressGatewayService) Delete(ctx context.Context, req resource
641642
return conn.DeleteExpressGatewayService(ctx, &input)
642643
},
643644
func(err error) (bool, error) {
645+
// Retry when service is in DRAINING status - it's not yet ready for deletion
646+
if errs.IsAErrorMessageContains[*awstypes.ServiceNotActiveException](err, "Service is in DRAINING status") {
647+
return true, err
648+
}
649+
// Don't retry for other errors
644650
if errs.IsA[*awstypes.InvalidParameterException](err) || errs.IsA[*awstypes.ServiceNotActiveException](err) {
645651
return false, err
646652
}

0 commit comments

Comments
 (0)