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_db_instance_automated_backups_replication: Guard against status code capitalization changes #33369

Merged
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
3 changes: 3 additions & 0 deletions .changelog/33369.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
resource/aws_redshift_cluster: Fix `unexpected state` errors on resource Create
```
14 changes: 9 additions & 5 deletions internal/service/rds/instance_automated_backups_replication.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"context"
"log"
"strconv"
"strings"
"time"

"github.com/aws/aws-sdk-go/aws"
Expand All @@ -23,10 +24,11 @@ import (
"github.com/hashicorp/terraform-provider-aws/internal/verify"
)

// AWS flip-flop on the capitalization of status codes. Use uppercase.
const (
InstanceAutomatedBackupStatusPending = "Pending"
InstanceAutomatedBackupStatusReplicating = "Replicating"
InstanceAutomatedBackupStatusRetained = "Retained"
InstanceAutomatedBackupStatusPending = "PENDING"
InstanceAutomatedBackupStatusReplicating = "REPLICATING"
InstanceAutomatedBackupStatusRetained = "RETAINED"
)

// @SDKResource("aws_db_instance_automated_backups_replication")
Expand Down Expand Up @@ -189,7 +191,8 @@ func FindDBInstanceAutomatedBackupByARN(ctx context.Context, conn *rds.RDS, arn
return nil, err
}

if status := aws.StringValue(output.Status); status == InstanceAutomatedBackupStatusRetained {
// AWS flip-flop on the capitalization of status codes. Case-insensitive comparison.
if status := aws.StringValue(output.Status); strings.EqualFold(status, InstanceAutomatedBackupStatusRetained) {
// If the automated backup is retained, the replication is stopped.
return nil, &retry.NotFoundError{
Message: status,
Expand Down Expand Up @@ -260,7 +263,8 @@ func statusDBInstanceAutomatedBackup(ctx context.Context, conn *rds.RDS, arn str
return nil, "", err
}

return output, aws.StringValue(output.Status), nil
// AWS flip-flop on the capitalization of status codes. Convert to uppercase.
return output, strings.ToUpper(aws.StringValue(output.Status)), nil
}
}

Expand Down
Loading