Skip to content

Commit

Permalink
Merge pull request hashicorp#40601 from hashicorp/b-rds-allocated_sto…
Browse files Browse the repository at this point in the history
…rage_modify

r/rds_cluster: fix wait error when modifying `allocated_storage`
  • Loading branch information
johnsonaj authored Dec 17, 2024
2 parents f37a17b + 6ff3cf0 commit 4b38a12
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 7 deletions.
3 changes: 3 additions & 0 deletions .changelog/40601.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
resource/aws_rds_cluster: Fix issue with waiter when modifying `allocated_storage`
```
1 change: 1 addition & 0 deletions internal/service/rds/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -2050,6 +2050,7 @@ func waitDBClusterUpdated(ctx context.Context, conn *rds.Client, id string, wait
clusterStatusRenaming,
clusterStatusResettingMasterCredentials,
clusterStatusScalingCompute,
clusterStatusScalingStorage,
clusterStatusUpgrading,
}
if waitNoPendingModifiedValues {
Expand Down
48 changes: 41 additions & 7 deletions internal/service/rds/cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -729,7 +729,7 @@ func TestAccRDSCluster_storageTypeAuroraUpdateAuroraIopt1(t *testing.T) {
})
}

func TestAccRDSCluster_allocatedStorage(t *testing.T) {
func TestAccRDSCluster_allocatedStorage_io1(t *testing.T) {
if testing.Short() {
t.Skip("skipping long-running test in short mode")
}
Expand All @@ -746,7 +746,7 @@ func TestAccRDSCluster_allocatedStorage(t *testing.T) {
CheckDestroy: testAccCheckClusterDestroy(ctx),
Steps: []resource.TestStep{
{
Config: testAccClusterConfig_allocatedStorage(rName),
Config: testAccClusterConfig_allocatedStorage(rName, "io1", 100, 1000),
Check: resource.ComposeTestCheckFunc(
testAccCheckClusterExists(ctx, resourceName, &dbCluster),
resource.TestCheckResourceAttr(resourceName, names.AttrAllocatedStorage, "100"),
Expand All @@ -756,6 +756,40 @@ func TestAccRDSCluster_allocatedStorage(t *testing.T) {
})
}

func TestAccRDSCluster_allocatedStorage_gp3(t *testing.T) {
if testing.Short() {
t.Skip("skipping long-running test in short mode")
}

ctx := acctest.Context(t)
var dbCluster types.DBCluster
rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix)
resourceName := "aws_rds_cluster.test"

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { acctest.PreCheck(ctx, t) },
ErrorCheck: acctest.ErrorCheck(t, names.RDSServiceID),
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories,
CheckDestroy: testAccCheckClusterDestroy(ctx),
Steps: []resource.TestStep{
{
Config: testAccClusterConfig_allocatedStorage(rName, "gp3", 400, 12000),
Check: resource.ComposeTestCheckFunc(
testAccCheckClusterExists(ctx, resourceName, &dbCluster),
resource.TestCheckResourceAttr(resourceName, names.AttrAllocatedStorage, "400"),
),
},
{
Config: testAccClusterConfig_allocatedStorage(rName, "gp3", 500, 12000),
Check: resource.ComposeTestCheckFunc(
testAccCheckClusterExists(ctx, resourceName, &dbCluster),
resource.TestCheckResourceAttr(resourceName, names.AttrAllocatedStorage, "500"),
),
},
},
})
}

// Verify storage_type from aurora-iopt1 to aurora
func TestAccRDSCluster_storageTypeAuroraIopt1UpdateAurora(t *testing.T) {
if testing.Short() {
Expand Down Expand Up @@ -3669,15 +3703,15 @@ resource "aws_db_instance" "test" {
`, tfrds.ClusterEnginePostgres, mainInstanceClasses, rName, sType))
}

func testAccClusterConfig_allocatedStorage(rName string) string {
func testAccClusterConfig_allocatedStorage(rName, storageType string, allocatedStorage, iops int) string {
return acctest.ConfigCompose(
testAccConfig_ClusterSubnetGroup(rName),
fmt.Sprintf(`
data "aws_rds_orderable_db_instance" "test" {
engine = %[1]q
engine_latest_version = true
preferred_instance_classes = [%[2]s]
storage_type = "io1"
storage_type = %[4]q
supports_iops = true
supports_clusters = true
}
Expand All @@ -3690,13 +3724,13 @@ resource "aws_rds_cluster" "test" {
engine = data.aws_rds_orderable_db_instance.test.engine
engine_version = data.aws_rds_orderable_db_instance.test.engine_version
storage_type = data.aws_rds_orderable_db_instance.test.storage_type
allocated_storage = 100
iops = 1000
allocated_storage = %[5]d
iops = %[6]d
master_password = "mustbeeightcharaters"
master_username = "test"
skip_final_snapshot = true
}
`, tfrds.ClusterEngineMySQL, mainInstanceClasses, rName))
`, tfrds.ClusterEngineMySQL, mainInstanceClasses, rName, storageType, allocatedStorage, iops))
}

func testAccClusterConfig_iops(rName string) string {
Expand Down
1 change: 1 addition & 0 deletions internal/service/rds/consts.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ const (
clusterStatusRenaming = "renaming"
clusterStatusResettingMasterCredentials = "resetting-master-credentials"
clusterStatusScalingCompute = "scaling-compute"
clusterStatusScalingStorage = "scaling-storage"
clusterStatusUpgrading = "upgrading"

// Non-standard status values.
Expand Down

0 comments on commit 4b38a12

Please sign in to comment.