-
Notifications
You must be signed in to change notification settings - Fork 9.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixing global rds by allowing for optional parameters on cluster #7213
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -701,7 +701,7 @@ func TestAccAWSRDSCluster_GlobalClusterIdentifier_Add(t *testing.T) { | |
CheckDestroy: testAccCheckAWSClusterDestroy, | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: testAccAWSRDSClusterConfig_EngineMode(rName, "global"), | ||
Config: testAccAWSRDSClusterConfig_GlobalEngineMode(rName), | ||
Check: resource.ComposeTestCheckFunc( | ||
testAccCheckAWSClusterExists(resourceName, &dbCluster1), | ||
resource.TestCheckResourceAttr(resourceName, "global_cluster_identifier", ""), | ||
|
@@ -735,7 +735,7 @@ func TestAccAWSRDSCluster_GlobalClusterIdentifier_Remove(t *testing.T) { | |
), | ||
}, | ||
{ | ||
Config: testAccAWSRDSClusterConfig_EngineMode(rName, "global"), | ||
Config: testAccAWSRDSClusterConfig_GlobalEngineMode(rName), | ||
Check: resource.ComposeTestCheckFunc( | ||
testAccCheckAWSClusterExists(resourceName, &dbCluster1), | ||
resource.TestCheckResourceAttr(resourceName, "global_cluster_identifier", ""), | ||
|
@@ -2250,6 +2250,22 @@ resource "aws_rds_cluster" "test" { | |
`, rName, deletionProtection) | ||
} | ||
|
||
func testAccAWSRDSClusterConfig_GlobalEngineMode(rName string) string { | ||
return fmt.Sprintf(` | ||
%s | ||
|
||
resource "aws_rds_cluster" "test" { | ||
depends_on = ["aws_db_subnet_group.dbsubnet"] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Instead of using db_subnet_group_name = "${aws_db_subnet_group.dbsubnet.name}" |
||
cluster_identifier = %q | ||
engine_mode = "global" | ||
db_subnet_group_name = %q | ||
master_password = "barbarbarbar" | ||
master_username = "foo" | ||
skip_final_snapshot = true | ||
} | ||
`, testAccAWSRDSClusterConfig_GlobalNetwork(rName), rName, rName) | ||
} | ||
|
||
func testAccAWSRDSClusterConfig_EngineMode(rName, engineMode string) string { | ||
return fmt.Sprintf(` | ||
resource "aws_rds_cluster" "test" { | ||
|
@@ -2262,40 +2278,76 @@ resource "aws_rds_cluster" "test" { | |
`, rName, engineMode) | ||
} | ||
|
||
func testAccAWSRDSClusterConfig_GlobalNetwork(rName string) string { | ||
return fmt.Sprintf(` | ||
data "aws_availability_zones" "azs" { } | ||
|
||
resource "aws_vpc" "vpc" { | ||
cidr_block = "10.0.0.0/16" | ||
tags = { | ||
Name = "terraform-acctest-rds-cluster-global-cross-region" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Setting up cross-region acceptance testing is a pretty complicated undertaking (see also: |
||
} | ||
} | ||
|
||
resource "aws_subnet" "subnets" { | ||
count = 2 | ||
vpc_id = "${aws_vpc.vpc.id}" | ||
availability_zone = "${data.aws_availability_zones.azs.names[count.index]}" | ||
cidr_block = "10.0.${count.index}.0/24" | ||
tags = { | ||
Name = "tf-acc-rds-cluster-global-cross-region-replica-${count.index}" | ||
} | ||
} | ||
|
||
resource "aws_db_subnet_group" "dbsubnet" { | ||
name = %q | ||
subnet_ids = ["${aws_subnet.subnets.*.id}"] | ||
}`, rName) | ||
|
||
} | ||
|
||
func testAccAWSRDSClusterConfig_GlobalClusterIdentifier(rName string) string { | ||
return fmt.Sprintf(` | ||
%s | ||
|
||
resource "aws_rds_global_cluster" "test" { | ||
global_cluster_identifier = %q | ||
} | ||
|
||
resource "aws_rds_cluster" "test" { | ||
depends_on = ["aws_db_subnet_group.dbsubnet"] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
cluster_identifier = %q | ||
global_cluster_identifier = "${aws_rds_global_cluster.test.id}" | ||
engine_mode = "global" | ||
master_password = "barbarbarbar" | ||
master_username = "foo" | ||
skip_final_snapshot = true | ||
db_subnet_group_name = "${aws_db_subnet_group.dbsubnet.name}" | ||
} | ||
`, rName, rName) | ||
`, testAccAWSRDSClusterConfig_GlobalNetwork(rName), rName, rName) | ||
} | ||
|
||
func testAccAWSRDSClusterConfig_GlobalClusterIdentifier_Update(rName, globalClusterIdentifierResourceName string) string { | ||
return fmt.Sprintf(` | ||
%s | ||
|
||
resource "aws_rds_global_cluster" "test" { | ||
count = 2 | ||
|
||
global_cluster_identifier = "%s-${count.index}" | ||
} | ||
|
||
resource "aws_rds_cluster" "test" { | ||
depends_on = ["aws_db_subnet_group.dbsubnet"] | ||
cluster_identifier = %q | ||
global_cluster_identifier = "${%s.id}" | ||
engine_mode = "global" | ||
master_password = "barbarbarbar" | ||
master_username = "foo" | ||
skip_final_snapshot = true | ||
db_subnet_group_name = %q | ||
} | ||
`, rName, rName, globalClusterIdentifierResourceName) | ||
`, testAccAWSRDSClusterConfig_GlobalNetwork(rName), rName, rName, globalClusterIdentifierResourceName, rName) | ||
} | ||
|
||
func testAccAWSRDSClusterConfig_ScalingConfiguration(rName string, autoPause bool, maxCapacity, minCapacity, secondsUntilAutoPause int) string { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
name
is not an attribute in this resource's schema, so can cause a panic as found by the acceptance testing:Will fix this on merge.