Skip to content

Commit

Permalink
Merge pull request #5980 from terraform-providers/f-aws_rds_cluster-e…
Browse files Browse the repository at this point in the history
…ngine_mode-parallelquery

resource/aws_rds_cluster: Support parallelquery engine_mode
  • Loading branch information
bflad authored Sep 25, 2018
2 parents c360851 + 691137f commit fd4c793
Show file tree
Hide file tree
Showing 3 changed files with 125 additions and 12 deletions.
1 change: 1 addition & 0 deletions aws/resource_aws_rds_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ func resourceAwsRDSCluster() *schema.Resource {
ForceNew: true,
Default: "provisioned",
ValidateFunc: validation.StringInSlice([]string{
"parallelquery",
"provisioned",
"serverless",
}, false),
Expand Down
134 changes: 123 additions & 11 deletions aws/resource_aws_rds_cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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" {
Expand All @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion website/docs/r/rds_cluster.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit fd4c793

Please sign in to comment.