From 691137f24b38e845711598e9a0cef2e3c6b0fbe7 Mon Sep 17 00:00:00 2001 From: Brian Flad Date: Tue, 25 Sep 2018 07:52:15 -0400 Subject: [PATCH] resource/aws_rds_cluster: Support parallelquery engine_mode ``` --- PASS: TestAccAWSRDSCluster_EngineMode_ParallelQuery (111.05s) --- PASS: TestAccAWSRDSCluster_SnapshotIdentifier_EngineMode_Provisioned (343.28s) --- PASS: TestAccAWSRDSCluster_SnapshotIdentifier_EngineMode_ParallelQuery (385.52s) ``` --- aws/resource_aws_rds_cluster.go | 1 + aws/resource_aws_rds_cluster_test.go | 134 +++++++++++++++++++++-- website/docs/r/rds_cluster.html.markdown | 2 +- 3 files changed, 125 insertions(+), 12 deletions(-) diff --git a/aws/resource_aws_rds_cluster.go b/aws/resource_aws_rds_cluster.go index 2f1c0e7e41e..7f253e470f0 100644 --- a/aws/resource_aws_rds_cluster.go +++ b/aws/resource_aws_rds_cluster.go @@ -126,6 +126,7 @@ func resourceAwsRDSCluster() *schema.Resource { ForceNew: true, Default: "provisioned", ValidateFunc: validation.StringInSlice([]string{ + "parallelquery", "provisioned", "serverless", }, false), diff --git a/aws/resource_aws_rds_cluster_test.go b/aws/resource_aws_rds_cluster_test.go index 8cf63851c6e..35f1de8e10d 100644 --- a/aws/resource_aws_rds_cluster_test.go +++ b/aws/resource_aws_rds_cluster_test.go @@ -489,6 +489,40 @@ func TestAccAWSRDSCluster_EngineMode(t *testing.T) { }) } +func TestAccAWSRDSCluster_EngineMode_ParallelQuery(t *testing.T) { + var dbCluster1 rds.DBCluster + + rName := acctest.RandomWithPrefix("tf-acc-test") + resourceName := "aws_rds_cluster.test" + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testAccCheckAWSClusterDestroy, + Steps: []resource.TestStep{ + { + Config: testAccAWSRDSClusterConfig_EngineMode(rName, "parallelquery"), + Check: resource.ComposeTestCheckFunc( + testAccCheckAWSClusterExists(resourceName, &dbCluster1), + resource.TestCheckResourceAttr(resourceName, "engine_mode", "parallelquery"), + ), + }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + ImportStateVerifyIgnore: []string{ + "apply_immediately", + "cluster_identifier_prefix", + "master_password", + "skip_final_snapshot", + "snapshot_identifier", + }, + }, + }, + }) +} + func TestAccAWSRDSCluster_EngineVersion(t *testing.T) { var dbCluster rds.DBCluster rInt := acctest.RandInt() @@ -615,12 +649,46 @@ func TestAccAWSRDSCluster_SnapshotIdentifier(t *testing.T) { }) } -func TestAccAWSRDSCluster_SnapshotIdentifier_EngineMode(t *testing.T) { - // NOTE: As of August 10, 2018: Attempting to create a serverless cluster - // from snapshot currently leaves those clusters stuck in "creating" - // for upwards of a few hours. AWS likely needs to resolve something - // upstream or provide a helpful error. This test is left here to - // potentially be updated in the future if that issue is resolved. +func TestAccAWSRDSCluster_SnapshotIdentifier_EngineMode_ParallelQuery(t *testing.T) { + var dbCluster, sourceDbCluster rds.DBCluster + var dbClusterSnapshot rds.DBClusterSnapshot + + rName := acctest.RandomWithPrefix("tf-acc-test") + sourceDbResourceName := "aws_rds_cluster.source" + snapshotResourceName := "aws_db_cluster_snapshot.test" + resourceName := "aws_rds_cluster.test" + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testAccCheckAWSDBInstanceDestroy, + Steps: []resource.TestStep{ + { + Config: testAccAWSRDSClusterConfig_SnapshotIdentifier_EngineMode(rName, "parallelquery"), + Check: resource.ComposeTestCheckFunc( + testAccCheckAWSClusterExists(sourceDbResourceName, &sourceDbCluster), + testAccCheckDbClusterSnapshotExists(snapshotResourceName, &dbClusterSnapshot), + testAccCheckAWSClusterExists(resourceName, &dbCluster), + resource.TestCheckResourceAttr(resourceName, "engine_mode", "parallelquery"), + ), + }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + ImportStateVerifyIgnore: []string{ + "apply_immediately", + "cluster_identifier_prefix", + "master_password", + "skip_final_snapshot", + "snapshot_identifier", + }, + }, + }, + }) +} + +func TestAccAWSRDSCluster_SnapshotIdentifier_EngineMode_Provisioned(t *testing.T) { var dbCluster, sourceDbCluster rds.DBCluster var dbClusterSnapshot rds.DBClusterSnapshot @@ -659,6 +727,49 @@ func TestAccAWSRDSCluster_SnapshotIdentifier_EngineMode(t *testing.T) { }) } +func TestAccAWSRDSCluster_SnapshotIdentifier_EngineMode_Serverless(t *testing.T) { + // The below is according to AWS Support. This test can be updated in the future + // to initialize some data. + t.Skip("serverless does not support snapshot restore on an empty volume") + + var dbCluster, sourceDbCluster rds.DBCluster + var dbClusterSnapshot rds.DBClusterSnapshot + + rName := acctest.RandomWithPrefix("tf-acc-test") + sourceDbResourceName := "aws_rds_cluster.source" + snapshotResourceName := "aws_db_cluster_snapshot.test" + resourceName := "aws_rds_cluster.test" + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testAccCheckAWSDBInstanceDestroy, + Steps: []resource.TestStep{ + { + Config: testAccAWSRDSClusterConfig_SnapshotIdentifier_EngineMode(rName, "serverless"), + Check: resource.ComposeTestCheckFunc( + testAccCheckAWSClusterExists(sourceDbResourceName, &sourceDbCluster), + testAccCheckDbClusterSnapshotExists(snapshotResourceName, &dbClusterSnapshot), + testAccCheckAWSClusterExists(resourceName, &dbCluster), + resource.TestCheckResourceAttr(resourceName, "engine_mode", "serverless"), + ), + }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + ImportStateVerifyIgnore: []string{ + "apply_immediately", + "cluster_identifier_prefix", + "master_password", + "skip_final_snapshot", + "snapshot_identifier", + }, + }, + }, + }) +} + func TestAccAWSRDSCluster_SnapshotIdentifier_Tags(t *testing.T) { var dbCluster, sourceDbCluster rds.DBCluster var dbClusterSnapshot rds.DBClusterSnapshot @@ -1699,10 +1810,11 @@ resource "aws_rds_cluster" "test" { func testAccAWSRDSClusterConfig_SnapshotIdentifier_EngineMode(rName, engineMode string) string { return fmt.Sprintf(` resource "aws_rds_cluster" "source" { - cluster_identifier = "%s-source" - master_password = "barbarbarbar" - master_username = "foo" - skip_final_snapshot = true + cluster_identifier = "%s-source" + engine_mode = %q + master_password = "barbarbarbar" + master_username = "foo" + skip_final_snapshot = true } resource "aws_db_cluster_snapshot" "test" { @@ -1716,7 +1828,7 @@ resource "aws_rds_cluster" "test" { skip_final_snapshot = true snapshot_identifier = "${aws_db_cluster_snapshot.test.id}" } -`, rName, rName, rName, engineMode) +`, rName, engineMode, rName, rName, engineMode) } func testAccAWSRDSClusterConfig_SnapshotIdentifier_Tags(rName string) string { diff --git a/website/docs/r/rds_cluster.html.markdown b/website/docs/r/rds_cluster.html.markdown index 706534541e9..93c7884098c 100644 --- a/website/docs/r/rds_cluster.html.markdown +++ b/website/docs/r/rds_cluster.html.markdown @@ -113,7 +113,7 @@ Default: A 30-minute window selected at random from an 8-hour block of time per * `iam_roles` - (Optional) A List of ARNs for the IAM roles to associate to the RDS Cluster. * `iam_database_authentication_enabled` - (Optional) Specifies whether or mappings of AWS Identity and Access Management (IAM) accounts to database accounts is enabled. Please see [AWS Documentation][6] for availability and limitations. * `engine` - (Optional) The name of the database engine to be used for this DB cluster. Defaults to `aurora`. Valid Values: `aurora`, `aurora-mysql`, `aurora-postgresql` -* `engine_mode` - (Optional) The database engine mode. Valid values: `provisioned`, `serverless`. Defaults to: `provisioned`. See the [RDS User Guide](https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/aurora-serverless.html) for limitations when using `serverless`. +* `engine_mode` - (Optional) The database engine mode. Valid values: `parallelquery`, `provisioned`, `serverless`. Defaults to: `provisioned`. See the [RDS User Guide](https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/aurora-serverless.html) for limitations when using `serverless`. * `engine_version` - (Optional) The database engine version. * `source_region` - (Optional) The source region for an encrypted replica DB cluster. * `enabled_cloudwatch_logs_exports` - (Optional) List of log types to export to cloudwatch. If omitted, no logs will be exported.