Skip to content

Commit

Permalink
resource/aws_rds_cluster: Add multimaster to engine_mode validation
Browse files Browse the repository at this point in the history
Reference: #9690

Output from acceptance testing:

```
--- PASS: TestAccAWSRDSCluster_EngineMode_Multimaster (141.13s)
```
  • Loading branch information
bflad committed Aug 9, 2019
1 parent 248b1b7 commit 0612479
Show file tree
Hide file tree
Showing 3 changed files with 102 additions and 1 deletion.
1 change: 1 addition & 0 deletions aws/resource_aws_rds_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ func resourceAwsRDSCluster() *schema.Resource {
Default: "provisioned",
ValidateFunc: validation.StringInSlice([]string{
"global",
"multimaster",
"parallelquery",
"provisioned",
"serverless",
Expand Down
85 changes: 85 additions & 0 deletions aws/resource_aws_rds_cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -788,6 +788,40 @@ func TestAccAWSRDSCluster_EngineMode_Global(t *testing.T) {
})
}

func TestAccAWSRDSCluster_EngineMode_Multimaster(t *testing.T) {
var dbCluster1 rds.DBCluster

rName := acctest.RandomWithPrefix("tf-acc-test")
resourceName := "aws_rds_cluster.test"

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckAWSClusterDestroy,
Steps: []resource.TestStep{
{
Config: testAccAWSRDSClusterConfig_EngineMode_Multimaster(rName),
Check: resource.ComposeTestCheckFunc(
testAccCheckAWSClusterExists(resourceName, &dbCluster1),
resource.TestCheckResourceAttr(resourceName, "engine_mode", "multimaster"),
),
},
{
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{
"apply_immediately",
"cluster_identifier_prefix",
"master_password",
"skip_final_snapshot",
"snapshot_identifier",
},
},
},
})
}

func TestAccAWSRDSCluster_EngineMode_ParallelQuery(t *testing.T) {
var dbCluster1 rds.DBCluster

Expand Down Expand Up @@ -2580,6 +2614,57 @@ resource "aws_rds_cluster" "test" {
`, rName, engineMode)
}

func testAccAWSRDSClusterConfig_EngineMode_Multimaster(rName string) string {
return fmt.Sprintf(`
data "aws_availability_zones" "available" {
state = "available"
}
resource "aws_vpc" "test" {
cidr_block = "10.0.0.0/16"
tags = {
Name = "tf-acc-test-rds-cluster-multimaster"
}
}
resource "aws_subnet" "test1" {
vpc_id = "${aws_vpc.test.id}"
cidr_block = "10.0.0.0/24"
availability_zone = "${data.aws_availability_zones.available.names[0]}"
tags = {
Name = "tf-acc-test-rds-cluster-multimaster"
}
}
resource "aws_subnet" "test2" {
vpc_id = "${aws_vpc.test.id}"
cidr_block = "10.0.1.0/24"
availability_zone = "${data.aws_availability_zones.available.names[1]}"
tags = {
Name = "tf-acc-test-rds-cluster-multimaster"
}
}
resource "aws_db_subnet_group" "test" {
name = %[1]q
subnet_ids = ["${aws_subnet.test1.id}", "${aws_subnet.test2.id}"]
}
# multimaster requires db_subnet_group_name
resource "aws_rds_cluster" "test" {
cluster_identifier = %[1]q
db_subnet_group_name = "${aws_db_subnet_group.test.name}"
engine_mode = "multimaster"
master_password = "barbarbarbar"
master_username = "foo"
skip_final_snapshot = true
}
`, rName)
}

func testAccAWSRDSClusterConfig_GlobalClusterIdentifier(rName string) string {
return fmt.Sprintf(`
resource "aws_rds_global_cluster" "test" {
Expand Down
17 changes: 16 additions & 1 deletion website/docs/r/rds_cluster.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,21 @@ resource "aws_rds_cluster" "postgresql" {
}
```

### Aurora Multi-Master Cluster

-> More information about Aurora Multi-Master Clusters can be found in the [RDS User Guide](https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/aurora-multi-master.html).

```hcl
resource "aws_rds_cluster" "example" {
cluster_identifier = "example"
db_subnet_group_name = "${aws_db_subnet_group.example.name}"
engine_mode = "multimaster"
master_password = "barbarbarbar"
master_username = "foo"
skip_final_snapshot = true
}
```

## Argument Reference

For more detailed documentation about each argument, refer to
Expand Down Expand Up @@ -116,7 +131,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](https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/UsingWithRDS.IAMDBAuth.html) 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: `global`, `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_mode` - (Optional) The database engine mode. Valid values: `global`, `multimaster`, `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. Updating this argument results in an outage. See the [Aurora MySQL](https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/AuroraMySQL.Updates.html) and [Aurora Postgres](https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/AuroraPostgreSQL.Updates.html) documentation for your configured engine to determine this value. For example with Aurora MySQL 2, a potential value for this argument is `5.7.mysql_aurora.2.03.2`.
* `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 0612479

Please sign in to comment.