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

r/aws_lexmodelsv2(test): handle PreconditionFailedException on delete #38661

Merged
merged 1 commit into from
Aug 5, 2024
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
9 changes: 9 additions & 0 deletions .changelog/38661.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
```release-note:bug
resource/aws_lexv2models_bot: Handle `PreconditionFailedException` on delete for resources deleted out-of-band
```
```release-note:bug
resource/aws_lexv2models_bot_locale: Handle `PreconditionFailedException` on delete for resources deleted out-of-band
```
```release-note:bug
resource/aws_lexv2models_bot_version: Handle `PreconditionFailedException` on delete for resources deleted out-of-band
```
8 changes: 4 additions & 4 deletions internal/service/lexv2models/bot.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/retry"
"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/framework"
"github.com/hashicorp/terraform-provider-aws/internal/framework/flex"
fwtypes "github.com/hashicorp/terraform-provider-aws/internal/framework/types"
Expand Down Expand Up @@ -370,8 +371,8 @@ func (r *resourceBot) Delete(ctx context.Context, req resource.DeleteRequest, re

_, err := conn.DeleteBot(ctx, in)
if err != nil {
var nfe *awstypes.ResourceNotFoundException
if errors.As(err, &nfe) {
if errs.IsA[*awstypes.ResourceNotFoundException](err) ||
errs.IsAErrorMessageContains[*awstypes.PreconditionFailedException](err, "does not exist") {
return
}
resp.Diagnostics.AddError(
Expand Down Expand Up @@ -474,8 +475,7 @@ func FindBotByID(ctx context.Context, conn *lexmodelsv2.Client, id string) (*lex

out, err := conn.DescribeBot(ctx, in)
if err != nil {
var nfe *awstypes.ResourceNotFoundException
if errors.As(err, &nfe) {
if errs.IsA[*awstypes.ResourceNotFoundException](err) {
return nil, &retry.NotFoundError{
LastError: err,
LastRequest: in,
Expand Down
8 changes: 4 additions & 4 deletions internal/service/lexv2models/bot_locale.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/retry"
"github.com/hashicorp/terraform-provider-aws/internal/create"
"github.com/hashicorp/terraform-provider-aws/internal/enum"
"github.com/hashicorp/terraform-provider-aws/internal/errs"
fwflex "github.com/hashicorp/terraform-provider-aws/internal/flex"
"github.com/hashicorp/terraform-provider-aws/internal/framework"
"github.com/hashicorp/terraform-provider-aws/internal/framework/flex"
Expand Down Expand Up @@ -342,8 +343,8 @@ func (r *resourceBotLocale) Delete(ctx context.Context, req resource.DeleteReque

_, err := conn.DeleteBotLocale(ctx, in)
if err != nil {
var nfe *awstypes.ResourceNotFoundException
if errors.As(err, &nfe) {
if errs.IsA[*awstypes.ResourceNotFoundException](err) ||
errs.IsAErrorMessageContains[*awstypes.PreconditionFailedException](err, "does not exist") {
return
}
resp.Diagnostics.AddError(
Expand Down Expand Up @@ -449,8 +450,7 @@ func FindBotLocaleByID(ctx context.Context, conn *lexmodelsv2.Client, id string)

out, err := conn.DescribeBotLocale(ctx, in)
if err != nil {
var nfe *awstypes.ResourceNotFoundException
if errors.As(err, &nfe) {
if errs.IsA[*awstypes.ResourceNotFoundException](err) {
return nil, &retry.NotFoundError{
LastError: err,
LastRequest: in,
Expand Down
8 changes: 4 additions & 4 deletions internal/service/lexv2models/bot_version.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/retry"
"github.com/hashicorp/terraform-provider-aws/internal/create"
"github.com/hashicorp/terraform-provider-aws/internal/enum"
"github.com/hashicorp/terraform-provider-aws/internal/errs"
fwflex "github.com/hashicorp/terraform-provider-aws/internal/flex"
"github.com/hashicorp/terraform-provider-aws/internal/framework"
"github.com/hashicorp/terraform-provider-aws/internal/framework/flex"
Expand Down Expand Up @@ -219,8 +220,8 @@ func (r *resourceBotVersion) Delete(ctx context.Context, req resource.DeleteRequ

_, err := conn.DeleteBotVersion(ctx, in)
if err != nil {
var nfe *awstypes.ResourceNotFoundException
if errors.As(err, &nfe) {
if errs.IsA[*awstypes.ResourceNotFoundException](err) ||
errs.IsAErrorMessageContains[*awstypes.PreconditionFailedException](err, "does not exist") {
return
}
resp.Diagnostics.AddError(
Expand Down Expand Up @@ -306,8 +307,7 @@ func FindBotVersionByID(ctx context.Context, conn *lexmodelsv2.Client, id string

out, err := conn.DescribeBotVersion(ctx, in)
if err != nil {
var nfe *awstypes.ResourceNotFoundException
if errors.As(err, &nfe) {
if errs.IsA[*awstypes.ResourceNotFoundException](err) {
return nil, &retry.NotFoundError{
LastError: err,
LastRequest: in,
Expand Down
Loading