Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pinpoint Application & OpsWorks Application: Don't return an error on successful Delete #30101

Merged
merged 3 commits into from
Mar 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .changelog/30101.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
```release-note:bug
resource/aws_pinpoint_app: Don't return an error like `deleting Pinpoint Application (...): %!s()` after successful Delete
```

```release-note:bug
resource/aws_opsworks_application: Don't return an error like `deleting OpsWorks Application (...): %!s()` after successful Delete
```
15 changes: 8 additions & 7 deletions internal/service/opsworks/application.go
Original file line number Diff line number Diff line change
Expand Up @@ -376,19 +376,20 @@ func resourceApplicationDelete(ctx context.Context, d *schema.ResourceData, meta
var diags diag.Diagnostics
conn := meta.(*conns.AWSClient).OpsWorksConn()

req := &opsworks.DeleteAppInput{
log.Printf("[DEBUG] Deleting OpsWorks Application: %s", d.Id())
_, err := conn.DeleteAppWithContext(ctx, &opsworks.DeleteAppInput{
AppId: aws.String(d.Id()),
}

log.Printf("[DEBUG] Deleting OpsWorks application: %s", d.Id())

_, err := conn.DeleteAppWithContext(ctx, req)
})

if tfawserr.ErrCodeEquals(err, opsworks.ErrCodeResourceNotFoundException) {
return diags
}

return sdkdiag.AppendErrorf(diags, "deleting OpsWorks Application (%s): %s", d.Id(), err)
if err != nil {
return sdkdiag.AppendErrorf(diags, "deleting OpsWorks Application (%s): %s", d.Id(), err)
}

return diags
}

func resourceFindEnvironmentVariable(key string, vs []*opsworks.EnvironmentVariable) *opsworks.EnvironmentVariable {
Expand Down
8 changes: 6 additions & 2 deletions internal/service/pinpoint/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ func resourceAppDelete(ctx context.Context, d *schema.ResourceData, meta interfa
var diags diag.Diagnostics
conn := meta.(*conns.AWSClient).PinpointConn()

log.Printf("[DEBUG] Pinpoint Delete App: %s", d.Id())
log.Printf("[DEBUG] Deleting Pinpoint Application: %s", d.Id())
_, err := conn.DeleteAppWithContext(ctx, &pinpoint.DeleteAppInput{
ApplicationId: aws.String(d.Id()),
})
Expand All @@ -318,7 +318,11 @@ func resourceAppDelete(ctx context.Context, d *schema.ResourceData, meta interfa
return diags
}

return sdkdiag.AppendErrorf(diags, "deleting Pinpoint Application (%s): %s", d.Id(), err)
if err != nil {
return sdkdiag.AppendErrorf(diags, "deleting Pinpoint Application (%s): %s", d.Id(), err)
}

return diags
}

func expandCampaignHook(configs []interface{}) *pinpoint.CampaignHook {
Expand Down