@@ -525,7 +525,7 @@ func TestAccRDSCluster_availabilityZones(t *testing.T) {
525
525
})
526
526
}
527
527
528
- func TestAccRDSCluster_storageType (t * testing.T ) {
528
+ func TestAccRDSCluster_storageTypeIo1 (t * testing.T ) {
529
529
if testing .Short () {
530
530
t .Skip ("skipping long-running test in short mode" )
531
531
}
@@ -542,7 +542,7 @@ func TestAccRDSCluster_storageType(t *testing.T) {
542
542
CheckDestroy : testAccCheckClusterDestroy (ctx ),
543
543
Steps : []resource.TestStep {
544
544
{
545
- Config : testAccClusterConfig_storageType (rName ),
545
+ Config : testAccClusterConfig_storageTypeIo1 (rName ),
546
546
Check : resource .ComposeTestCheckFunc (
547
547
testAccCheckClusterExists (ctx , resourceName , & dbCluster ),
548
548
resource .TestCheckResourceAttr (resourceName , "storage_type" , "io1" ),
@@ -552,6 +552,101 @@ func TestAccRDSCluster_storageType(t *testing.T) {
552
552
})
553
553
}
554
554
555
+ // For backwards compatibility, the control plane should always return a blank string even if sending "aurora" as the storage type
556
+ func TestAccRDSCluster_storageTypeAuroraReturnsBlank (t * testing.T ) {
557
+ if testing .Short () {
558
+ t .Skip ("skipping long-running test in short mode" )
559
+ }
560
+
561
+ ctx := acctest .Context (t )
562
+ var dbCluster1 rds.DBCluster
563
+ rName := sdkacctest .RandomWithPrefix (acctest .ResourcePrefix )
564
+ storageTypeAurora := "aurora"
565
+ storageTypeEmpty := ""
566
+ resourceName := "aws_rds_cluster.test"
567
+
568
+ resource .ParallelTest (t , resource.TestCase {
569
+ PreCheck : func () { acctest .PreCheck (ctx , t ) },
570
+ ErrorCheck : acctest .ErrorCheck (t , rds .EndpointsID ),
571
+ ProtoV5ProviderFactories : acctest .ProtoV5ProviderFactories ,
572
+ CheckDestroy : testAccCheckClusterDestroy (ctx ),
573
+ Steps : []resource.TestStep {
574
+ {
575
+ Config : testAccClusterConfig_auroraStorageType (rName , storageTypeAurora ),
576
+ Check : resource .ComposeTestCheckFunc (
577
+ testAccCheckClusterExists (ctx , resourceName , & dbCluster1 ),
578
+ resource .TestCheckResourceAttr (resourceName , "storage_type" , storageTypeEmpty ),
579
+ ),
580
+ },
581
+ },
582
+ })
583
+ }
584
+
585
+ func TestAccRDSCluster_storageTypeAuroraIopt1 (t * testing.T ) {
586
+ if testing .Short () {
587
+ t .Skip ("skipping long-running test in short mode" )
588
+ }
589
+
590
+ ctx := acctest .Context (t )
591
+ var dbCluster rds.DBCluster
592
+ rName := sdkacctest .RandomWithPrefix (acctest .ResourcePrefix )
593
+ storageType := "aurora-iopt1"
594
+ resourceName := "aws_rds_cluster.test"
595
+
596
+ resource .ParallelTest (t , resource.TestCase {
597
+ PreCheck : func () { acctest .PreCheck (ctx , t ) },
598
+ ErrorCheck : acctest .ErrorCheck (t , rds .EndpointsID ),
599
+ ProtoV5ProviderFactories : acctest .ProtoV5ProviderFactories ,
600
+ CheckDestroy : testAccCheckClusterDestroy (ctx ),
601
+ Steps : []resource.TestStep {
602
+ {
603
+ Config : testAccClusterConfig_auroraStorageType (rName , storageType ),
604
+ Check : resource .ComposeTestCheckFunc (
605
+ testAccCheckClusterExists (ctx , resourceName , & dbCluster ),
606
+ resource .TestCheckResourceAttr (resourceName , "storage_type" , storageType ),
607
+ ),
608
+ },
609
+ },
610
+ })
611
+ }
612
+
613
+ func TestAccRDSCluster_storageTypeAuroraUpdateAuroraIopt1 (t * testing.T ) {
614
+ if testing .Short () {
615
+ t .Skip ("skipping long-running test in short mode" )
616
+ }
617
+
618
+ ctx := acctest .Context (t )
619
+ var dbCluster1 , dbCluster2 rds.DBCluster
620
+ rName := sdkacctest .RandomWithPrefix (acctest .ResourcePrefix )
621
+ storageTypeEmpty := ""
622
+ storageTypeAuroraIOPT1 := "aurora-iopt1"
623
+ resourceName := "aws_rds_cluster.test"
624
+
625
+ resource .ParallelTest (t , resource.TestCase {
626
+ PreCheck : func () { acctest .PreCheck (ctx , t ) },
627
+ ErrorCheck : acctest .ErrorCheck (t , rds .EndpointsID ),
628
+ ProtoV5ProviderFactories : acctest .ProtoV5ProviderFactories ,
629
+ CheckDestroy : testAccCheckClusterDestroy (ctx ),
630
+ Steps : []resource.TestStep {
631
+ {
632
+ Config : testAccClusterConfig_auroraStorageTypeNotDefined (rName ),
633
+ Check : resource .ComposeTestCheckFunc (
634
+ testAccCheckClusterExists (ctx , resourceName , & dbCluster1 ),
635
+ resource .TestCheckResourceAttr (resourceName , "storage_type" , storageTypeEmpty ),
636
+ ),
637
+ },
638
+ {
639
+ Config : testAccClusterConfig_auroraStorageType (rName , storageTypeAuroraIOPT1 ),
640
+ Check : resource .ComposeTestCheckFunc (
641
+ testAccCheckClusterExists (ctx , resourceName , & dbCluster2 ),
642
+ testAccCheckClusterNotRecreated (& dbCluster1 , & dbCluster2 ),
643
+ resource .TestCheckResourceAttr (resourceName , "storage_type" , storageTypeAuroraIOPT1 ),
644
+ ),
645
+ },
646
+ },
647
+ })
648
+ }
649
+
555
650
func TestAccRDSCluster_allocatedStorage (t * testing.T ) {
556
651
if testing .Short () {
557
652
t .Skip ("skipping long-running test in short mode" )
@@ -579,6 +674,45 @@ func TestAccRDSCluster_allocatedStorage(t *testing.T) {
579
674
})
580
675
}
581
676
677
+ // Verify storage_type from aurora-iopt1 to aurora
678
+ func TestAccRDSCluster_storageTypeAuroraIopt1UpdateAurora (t * testing.T ) {
679
+ if testing .Short () {
680
+ t .Skip ("skipping long-running test in short mode" )
681
+ }
682
+
683
+ ctx := acctest .Context (t )
684
+ var dbCluster1 , dbCluster2 rds.DBCluster
685
+ rName := sdkacctest .RandomWithPrefix (acctest .ResourcePrefix )
686
+ storageTypeAuroraIOPT1 := "aurora-iopt1"
687
+ storageTypeAurora := "aurora"
688
+ storageTypeEmpty := ""
689
+ resourceName := "aws_rds_cluster.test"
690
+
691
+ resource .ParallelTest (t , resource.TestCase {
692
+ PreCheck : func () { acctest .PreCheck (ctx , t ) },
693
+ ErrorCheck : acctest .ErrorCheck (t , rds .EndpointsID ),
694
+ ProtoV5ProviderFactories : acctest .ProtoV5ProviderFactories ,
695
+ CheckDestroy : testAccCheckClusterDestroy (ctx ),
696
+ Steps : []resource.TestStep {
697
+ {
698
+ Config : testAccClusterConfig_auroraStorageType (rName , storageTypeAuroraIOPT1 ),
699
+ Check : resource .ComposeTestCheckFunc (
700
+ testAccCheckClusterExists (ctx , resourceName , & dbCluster1 ),
701
+ resource .TestCheckResourceAttr (resourceName , "storage_type" , storageTypeAuroraIOPT1 ),
702
+ ),
703
+ },
704
+ {
705
+ Config : testAccClusterConfig_auroraStorageType (rName , storageTypeAurora ),
706
+ Check : resource .ComposeTestCheckFunc (
707
+ testAccCheckClusterExists (ctx , resourceName , & dbCluster2 ),
708
+ testAccCheckClusterNotRecreated (& dbCluster1 , & dbCluster2 ),
709
+ resource .TestCheckResourceAttr (resourceName , "storage_type" , storageTypeEmpty ),
710
+ ),
711
+ },
712
+ },
713
+ })
714
+ }
715
+
582
716
func TestAccRDSCluster_iops (t * testing.T ) {
583
717
if testing .Short () {
584
718
t .Skip ("skipping long-running test in short mode" )
@@ -2498,6 +2632,16 @@ func testAccCheckClusterRecreated(i, j *rds.DBCluster) resource.TestCheckFunc {
2498
2632
}
2499
2633
}
2500
2634
2635
+ func testAccCheckClusterNotRecreated (i , j * rds.DBCluster ) resource.TestCheckFunc {
2636
+ return func (s * terraform.State ) error {
2637
+ if ! aws .TimeValue (i .ClusterCreateTime ).Equal (aws .TimeValue (j .ClusterCreateTime )) {
2638
+ return errors .New ("RDS Cluster was recreated" )
2639
+ }
2640
+
2641
+ return nil
2642
+ }
2643
+ }
2644
+
2501
2645
func testAccClusterConfig_basic (rName string ) string {
2502
2646
return fmt .Sprintf (`
2503
2647
resource "aws_rds_cluster" "test" {
@@ -2801,7 +2945,7 @@ resource "aws_rds_cluster" "test" {
2801
2945
` , rName ))
2802
2946
}
2803
2947
2804
- func testAccClusterConfig_storageType (rName string ) string {
2948
+ func testAccClusterConfig_storageTypeIo1 (rName string ) string {
2805
2949
return fmt .Sprintf (`
2806
2950
resource "aws_rds_cluster" "test" {
2807
2951
apply_immediately = true
@@ -4493,6 +4637,59 @@ resource "aws_rds_cluster" "test" {
4493
4637
` , n , f )
4494
4638
}
4495
4639
4640
+ func testAccClusterConfig_auroraStorageType (rName , storageType string ) string {
4641
+ return fmt .Sprintf (`
4642
+ data "aws_rds_engine_version" "default" {
4643
+ engine = "aurora-postgresql"
4644
+ preferred_versions = ["14.7", "15.2"]
4645
+ }
4646
+
4647
+ data "aws_rds_orderable_db_instance" "default" {
4648
+ engine = data.aws_rds_engine_version.default.engine
4649
+ engine_version = data.aws_rds_engine_version.default.version
4650
+ preferred_instance_classes = ["db.m6g.large", "db.m5.large", "db.r5.large", "db.c5.large"]
4651
+ }
4652
+
4653
+ resource "aws_rds_cluster" "test" {
4654
+ apply_immediately = true
4655
+ cluster_identifier = %[1]q
4656
+ engine = data.aws_rds_engine_version.default.engine
4657
+ engine_version = data.aws_rds_engine_version.default.version
4658
+ master_password = "avoid-plaintext-passwords"
4659
+ master_username = "tfacctest"
4660
+ skip_final_snapshot = true
4661
+ storage_type = %[2]q
4662
+ }
4663
+
4664
+ ` , rName , storageType )
4665
+ }
4666
+
4667
+ func testAccClusterConfig_auroraStorageTypeNotDefined (rName string ) string {
4668
+ return fmt .Sprintf (`
4669
+ data "aws_rds_engine_version" "default" {
4670
+ engine = "aurora-postgresql"
4671
+ preferred_versions = ["14.7", "15.2"]
4672
+ }
4673
+
4674
+ data "aws_rds_orderable_db_instance" "default" {
4675
+ engine = data.aws_rds_engine_version.default.engine
4676
+ engine_version = data.aws_rds_engine_version.default.version
4677
+ preferred_instance_classes = ["db.m6g.large", "db.m5.large", "db.r5.large", "db.c5.large"]
4678
+ }
4679
+
4680
+ resource "aws_rds_cluster" "test" {
4681
+ apply_immediately = true
4682
+ cluster_identifier = %[1]q
4683
+ engine = data.aws_rds_engine_version.default.engine
4684
+ engine_version = data.aws_rds_engine_version.default.version
4685
+ master_password = "avoid-plaintext-passwords"
4686
+ master_username = "tfacctest"
4687
+ skip_final_snapshot = true
4688
+ }
4689
+
4690
+ ` , rName )
4691
+ }
4692
+
4496
4693
func testAccClusterConfig_enableHTTPEndpoint (rName string , enableHttpEndpoint bool ) string {
4497
4694
return fmt .Sprintf (`
4498
4695
resource "aws_rds_cluster" "test" {
0 commit comments