Skip to content
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

RDS Aurora Cross Region replication for encrypted clusters #2111

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion aws/resource_aws_rds_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,13 @@ func resourceAwsRDSCluster() *schema.Resource {
Optional: true,
},

"source_region": {
Type: schema.TypeString,
Optional: true,
ForceNew: true,
ConflictsWith: []string{"snapshot_identifier"},
},

"iam_roles": {
Type: schema.TypeSet,
Optional: true,
Expand Down Expand Up @@ -365,7 +372,8 @@ func resourceAwsRDSClusterCreate(d *schema.ResourceData, meta interface{}) error
Engine: aws.String(d.Get("engine").(string)),
StorageEncrypted: aws.Bool(d.Get("storage_encrypted").(bool)),
ReplicationSourceIdentifier: aws.String(d.Get("replication_source_identifier").(string)),
Tags: tags,
SourceRegion: aws.String(d.Get("source_region").(string)),
Tags: tags,
}

if attr, ok := d.GetOk("port"); ok {
Expand Down
34 changes: 34 additions & 0 deletions aws/resource_aws_rds_cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,40 @@ func TestAccAWSRDSCluster_basic(t *testing.T) {
})
}

func TestAccAWSRDSCluster_crossRegion(t *testing.T) {
var v rds.DBCluster

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckAWSClusterDestroy,
Steps: []resource.TestStep{
{
Config: testAccAWSClusterConfig(acctest.RandInt()),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we'll also need to create a config which sets up the cross-region replication, testAccAWSClusterConfig doesn't do it. Any minimalistic configuration will do in this context, but it should actually setup the replication and test this new behaviour/field - ideally we'd be checking the value of source_region, not just whether it's set.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a little out of my comfort zone. Unfortunately I don't really have the experience to do what you're asking, I'm not very experienced in writing go.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Author

@mitchelldavis44 mitchelldavis44 Jan 9, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@radeksimko is there any way we can have this merged? I'm not the guy to make more complex tests, but this is definitely a needed flag in terraform.

Check: resource.ComposeTestCheckFunc(
testAccCheckAWSClusterExists("aws_rds_cluster.default", &v),
resource.TestCheckResourceAttr(
"aws_rds_cluster.default", "storage_encrypted", "true"),
resource.TestCheckResourceAttr(
"aws_rds_cluster.default", "db_cluster_parameter_group_name", "default.aurora5.6"),
resource.TestCheckResourceAttrSet(
"aws_rds_cluster.default", "reader_endpoint"),
resource.TestCheckResourceAttrSet(
"aws_rds_cluster.default", "cluster_resource_id"),
resource.TestCheckResourceAttr(
"aws_rds_cluster.default", "engine", "aurora"),
resource.TestCheckResourceAttrSet(
"aws_rds_cluster.default", "engine_version"),
resource.TestCheckResourceAttrSet(
"aws_rds_cluster.default", "source_region"),
resource.TestCheckResourceAttrSet(
"aws_rds_cluster.default", "kms_key_id"),
),
},
},
})
}

func TestAccAWSRDSCluster_namePrefix(t *testing.T) {
var v rds.DBCluster

Expand Down