Skip to content

Commit

Permalink
Merge pull request #32287 from johanneswuerbach/fix-rds-wait
Browse files Browse the repository at this point in the history
rds/instance: Fix create returns unready instances
  • Loading branch information
ewbankkit authored Jun 29, 2023
2 parents 5c61579 + 3e5115d commit 0328b30
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
3 changes: 3 additions & 0 deletions .changelog/32287.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
resource/aws_db_instance: Fix resource Create returning instances not in the `available` state when `identifier_prefix` is specified
```
14 changes: 7 additions & 7 deletions internal/service/rds/instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -1563,7 +1563,7 @@ func resourceInstanceCreate(ctx context.Context, d *schema.ResourceData, meta in

var instance *rds.DBInstance
var err error
if instance, err = waitDBInstanceAvailableSDKv1(ctx, conn, d.Get("identifier").(string), d.Timeout(schema.TimeoutCreate)); err != nil {
if instance, err = waitDBInstanceAvailableSDKv1(ctx, conn, identifier, d.Timeout(schema.TimeoutCreate)); err != nil {
return sdkdiag.AppendErrorf(diags, "waiting for RDS DB Instance (%s) create: %s", identifier, err)
}

Expand Down Expand Up @@ -2373,17 +2373,16 @@ func findDBInstanceByIDSDKv1(ctx context.Context, conn *rds.RDS, id string) (*rd
LastRequest: input,
}
}

if err != nil {
return nil, err
}

if output == nil || len(output.DBInstances) == 0 || output.DBInstances[0] == nil {
if output == nil {
return nil, tfresource.NewEmptyResultError(input)
}

dbInstance := output.DBInstances[0]

return dbInstance, nil
return tfresource.AssertSinglePtrResult(output.DBInstances)
}

// findDBInstanceByIDSDKv2 in general should be called with a DbiResourceId of the form
Expand Down Expand Up @@ -2419,15 +2418,16 @@ func findDBInstanceByIDSDKv2(ctx context.Context, conn *rds_sdkv2.Client, id str
LastRequest: input,
}
}

if err != nil {
return nil, err
}

if output == nil || len(output.DBInstances) == 0 {
if output == nil {
return nil, tfresource.NewEmptyResultError(input)
}

return &output.DBInstances[0], nil
return tfresource.AssertSingleValueResult(output.DBInstances)
}

func statusDBInstanceSDKv1(ctx context.Context, conn *rds.RDS, id string) retry.StateRefreshFunc {
Expand Down

0 comments on commit 0328b30

Please sign in to comment.