diff --git a/aws/resource_aws_rds_cluster_instance_test.go b/aws/resource_aws_rds_cluster_instance_test.go index 178a5df9774..481535cc564 100644 --- a/aws/resource_aws_rds_cluster_instance_test.go +++ b/aws/resource_aws_rds_cluster_instance_test.go @@ -382,9 +382,11 @@ func TestAccAWSRDSClusterInstance_withInstanceEnhancedMonitor(t *testing.T) { }) } -func TestAccAWSRDSClusterInstance_withInstancePerformanceInsights(t *testing.T) { - var v rds.DBInstance - keyRegex := regexp.MustCompile("^arn:aws:kms:") +func TestAccAWSRDSClusterInstance_PerformanceInsightsEnabled_AuroraMysql1(t *testing.T) { + var dbInstance rds.DBInstance + kmsKeyResourceName := "aws_kms_key.test" + resourceName := "aws_rds_cluster_instance.test" + rName := acctest.RandomWithPrefix("tf-acc-test") resource.ParallelTest(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, @@ -392,18 +394,79 @@ func TestAccAWSRDSClusterInstance_withInstancePerformanceInsights(t *testing.T) CheckDestroy: testAccCheckAWSClusterDestroy, Steps: []resource.TestStep{ { - Config: testAccAWSClusterInstancePerformanceInsights(acctest.RandInt()), + Config: testAccAWSClusterInstanceConfigPerformanceInsightsEnabledAuroraMysql1(rName), Check: resource.ComposeTestCheckFunc( - testAccCheckAWSClusterInstanceExists("aws_rds_cluster_instance.cluster_instances", &v), - testAccCheckAWSDBClusterInstanceAttributes(&v), - resource.TestCheckResourceAttr( - "aws_rds_cluster_instance.cluster_instances", "performance_insights_enabled", "true"), - resource.TestMatchResourceAttr( - "aws_rds_cluster_instance.cluster_instances", "performance_insights_kms_key_id", keyRegex), + testAccCheckAWSClusterInstanceExists(resourceName, &dbInstance), + resource.TestCheckResourceAttr(resourceName, "performance_insights_enabled", "true"), + resource.TestCheckResourceAttrPair(resourceName, "performance_insights_kms_key_id", kmsKeyResourceName, "arn"), ), }, { - ResourceName: "aws_rds_cluster_instance.cluster_instances", + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + ImportStateVerifyIgnore: []string{ + "apply_immediately", + "identifier_prefix", + }, + }, + }, + }) +} + +func TestAccAWSRDSClusterInstance_PerformanceInsightsEnabled_AuroraMysql2(t *testing.T) { + var dbInstance rds.DBInstance + kmsKeyResourceName := "aws_kms_key.test" + resourceName := "aws_rds_cluster_instance.test" + rName := acctest.RandomWithPrefix("tf-acc-test") + + resource.ParallelTest(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testAccCheckAWSClusterDestroy, + Steps: []resource.TestStep{ + { + Config: testAccAWSClusterInstanceConfigPerformanceInsightsEnabledAuroraMysql2(rName), + Check: resource.ComposeTestCheckFunc( + testAccCheckAWSClusterInstanceExists(resourceName, &dbInstance), + resource.TestCheckResourceAttr(resourceName, "performance_insights_enabled", "true"), + resource.TestCheckResourceAttrPair(resourceName, "performance_insights_kms_key_id", kmsKeyResourceName, "arn"), + ), + }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + ImportStateVerifyIgnore: []string{ + "apply_immediately", + "identifier_prefix", + }, + }, + }, + }) +} + +func TestAccAWSRDSClusterInstance_PerformanceInsightsEnabled_AuroraPostgresql(t *testing.T) { + var dbInstance rds.DBInstance + kmsKeyResourceName := "aws_kms_key.test" + resourceName := "aws_rds_cluster_instance.test" + rName := acctest.RandomWithPrefix("tf-acc-test") + + resource.ParallelTest(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testAccCheckAWSClusterDestroy, + Steps: []resource.TestStep{ + { + Config: testAccAWSClusterInstanceConfigPerformanceInsightsEnabledAuroraPostgresql(rName), + Check: resource.ComposeTestCheckFunc( + testAccCheckAWSClusterInstanceExists(resourceName, &dbInstance), + resource.TestCheckResourceAttr(resourceName, "performance_insights_enabled", "true"), + resource.TestCheckResourceAttrPair(resourceName, "performance_insights_kms_key_id", kmsKeyResourceName, "arn"), + ), + }, + { + ResourceName: resourceName, ImportState: true, ImportStateVerify: true, ImportStateVerifyIgnore: []string{ @@ -787,65 +850,84 @@ resource "aws_db_parameter_group" "bar" { `, n, n, n, n, n, n) } -func testAccAWSClusterInstancePerformanceInsights(n int) string { +func testAccAWSClusterInstanceConfigPerformanceInsightsEnabledAuroraMysql1(rName string) string { return fmt.Sprintf(` -resource "aws_kms_key" "foo" { - description = "Terraform acc test %d" +resource "aws_kms_key" "test" { + deletion_window_in_days = 7 +} - policy = <