Skip to content

Commit

Permalink
aws_medialive_channel: check NotFound during delete
Browse files Browse the repository at this point in the history
  • Loading branch information
johnsonaj committed Feb 9, 2024
1 parent 6c816ba commit d3c3e47
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions internal/service/medialive/channel.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"github.com/hashicorp/terraform-provider-aws/internal/conns"
"github.com/hashicorp/terraform-provider-aws/internal/create"
"github.com/hashicorp/terraform-provider-aws/internal/enum"
"github.com/hashicorp/terraform-provider-aws/internal/errs"
"github.com/hashicorp/terraform-provider-aws/internal/flex"
tftags "github.com/hashicorp/terraform-provider-aws/internal/tags"
"github.com/hashicorp/terraform-provider-aws/internal/tfresource"
Expand Down Expand Up @@ -958,6 +959,10 @@ func resourceChannelDelete(ctx context.Context, d *schema.ResourceData, meta int

channel, err := FindChannelByID(ctx, conn, d.Id())

if tfresource.NotFound(err) {
return diags
}

if err != nil {
return create.AppendDiagError(diags, names.MediaLive, create.ErrActionDeleting, ResNameChannel, d.Id(), err)
}
Expand All @@ -972,12 +977,11 @@ func resourceChannelDelete(ctx context.Context, d *schema.ResourceData, meta int
ChannelId: aws.String(d.Id()),
})

if err != nil {
var nfe *types.NotFoundException
if errors.As(err, &nfe) {
return diags
}
if errs.IsA[*types.NotFoundException](err) {
return diags
}

if err != nil {
return create.AppendDiagError(diags, names.MediaLive, create.ErrActionDeleting, ResNameChannel, d.Id(), err)
}

Expand Down Expand Up @@ -1128,15 +1132,15 @@ func FindChannelByID(ctx context.Context, conn *medialive.Client, id string) (*m
ChannelId: aws.String(id),
}
out, err := conn.DescribeChannel(ctx, in)
if err != nil {
var nfe *types.NotFoundException
if errors.As(err, &nfe) {
return nil, &retry.NotFoundError{
LastError: err,
LastRequest: in,
}

if errs.IsA[*types.NotFoundException](err) {
return nil, &retry.NotFoundError{
LastError: err,
LastRequest: in,
}
}

if err != nil {
return nil, err
}

Expand Down

0 comments on commit d3c3e47

Please sign in to comment.