Skip to content

Commit

Permalink
Merge pull request #39498 from hashicorp/td-create-DiagError
Browse files Browse the repository at this point in the history
r/aws_medialive_multiplex: handle read failure during delete
  • Loading branch information
jar-b authored Sep 26, 2024
2 parents b185632 + 1119b7a commit 470e2a4
Show file tree
Hide file tree
Showing 10 changed files with 104 additions and 29 deletions.
3 changes: 3 additions & 0 deletions .changelog/39498.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
resource/aws_medialive_multiplex: Fix to properly handle read failures during delete operations which were previously ignored
```
21 changes: 0 additions & 21 deletions internal/create/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,27 +73,13 @@ func AppendDiagError(diags diag.Diagnostics, service, action, resource, id strin
)
}

// DiagError returns a 1-length diag.Diagnostics with a diag.Error-level diag.Diagnostic
// with a standardized error message
func DiagError(service, action, resource, id string, gotError error) diag.Diagnostics {
return diag.Diagnostics{
diagError(service, action, resource, id, gotError),
}
}

func diagError(service, action, resource, id string, gotError error) diag.Diagnostic {
return diag.Diagnostic{
Severity: diag.Error,
Summary: ProblemStandardMessage(service, action, resource, id, gotError),
}
}

func AppendDiagErrorMessage(diags diag.Diagnostics, service, action, resource, id, message string) diag.Diagnostics {
return append(diags,
diagError(service, action, resource, id, errors.New(message)),
)
}

func AppendDiagSettingError(diags diag.Diagnostics, service, resource, id, argument string, gotError error) diag.Diagnostics {
return append(diags,
diagError(service, fmt.Sprintf("%s %s", ErrActionSetting, argument), resource, id, gotError),
Expand All @@ -117,10 +103,3 @@ func WarnLog(service, action, resource, id string, gotError error) {
func LogNotFoundRemoveState(service, action, resource, id string) {
WarnLog(service, action, resource, id, errors.New("not found, removing from state"))
}

func DiagErrorFramework(service, action, resource, id string, gotError error) fwdiag.Diagnostic {
return fwdiag.NewErrorDiagnostic(
ProblemStandardMessage(service, action, resource, id, nil),
gotError.Error(),
)
}
4 changes: 2 additions & 2 deletions internal/service/medialive/multiplex.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import (

// @SDKResource("aws_medialive_multiplex", name="Multiplex")
// @Tags(identifierAttribute="arn")
// @Testing(existsType="github.com/aws/aws-sdk-go-v2/service/medialive;medialive.DescribeMultiplexOutput")
// @Testing(existsType="github.com/aws/aws-sdk-go-v2/service/medialive;medialive.DescribeMultiplexOutput", importIgnore="start_multiplex")
// @Testing(serialize=true)
func ResourceMultiplex() *schema.Resource {
return &schema.Resource{
Expand Down Expand Up @@ -244,7 +244,7 @@ func resourceMultiplexDelete(ctx context.Context, d *schema.ResourceData, meta i
}

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

if out.State == types.MultiplexStateRunning {
Expand Down
93 changes: 93 additions & 0 deletions internal/service/medialive/multiplex_tags_gen_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# SPDX-License-Identifier: MPL-2.0

resource "aws_medialive_multiplex" "test" {
name = %[1]q
name = var.rName
availability_zones = [data.aws_availability_zones.available.names[0], data.aws_availability_zones.available.names[1]]

multiplex_settings {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
provider "null" {}

resource "aws_medialive_multiplex" "test" {
name = %[1]q
name = var.rName
availability_zones = [data.aws_availability_zones.available.names[0], data.aws_availability_zones.available.names[1]]

multiplex_settings {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
provider "null" {}

resource "aws_medialive_multiplex" "test" {
name = %[1]q
name = var.rName
availability_zones = [data.aws_availability_zones.available.names[0], data.aws_availability_zones.available.names[1]]

multiplex_settings {
Expand Down
Loading

0 comments on commit 470e2a4

Please sign in to comment.