From d755fbd347793eb1292b47eb0d7d402f8302d823 Mon Sep 17 00:00:00 2001 From: Clint Shryock Date: Wed, 13 May 2015 11:21:06 -0500 Subject: [PATCH 1/6] provider/aws: Add docs for AWS RDS Read Replicate --- .../providers/aws/r/db_instance.html.markdown | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/website/source/docs/providers/aws/r/db_instance.html.markdown b/website/source/docs/providers/aws/r/db_instance.html.markdown index 61b5b6dcfb80..c536f8ee9ab1 100644 --- a/website/source/docs/providers/aws/r/db_instance.html.markdown +++ b/website/source/docs/providers/aws/r/db_instance.html.markdown @@ -48,7 +48,8 @@ The following arguments are supported: show up in logs, and it will be stored in the state file. * `username` - (Required) Username for the master DB user. * `availability_zone` - (Optional) The AZ for the RDS instance. -* `backup_retention_period` - (Optional) The days to retain backups for. +* `backup_retention_period` - (Optional) The days to retain backups for. Must be +`1` or greater to be a source for a [Read Replicate][1]. * `backup_window` - (Optional) The backup window. * `iops` - (Optional) The amount of provisioned IOPS. Setting this implies a storage_type of "io1". @@ -65,6 +66,17 @@ The following arguments are supported: * `apply_immediately` - (Optional) Specifies whether any database modifications are applied immediately, or during the next maintenance window. Default is `false`. See [Amazon RDS Documentation for more for more information.](http://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/Overview.DBInstance.Modifying.html) +* `replicate_source` - (Optional) Specifies that this resource is a Replicate +database, and to use this value as the source database. This correlates to the +`identifier` of another Amazon RDS Database to replicate. See +[DB Instance Replication][1] and +[Working with PostgreSQL and MySQL Read Replicas](http://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/USER_ReadRepl.html) for + more information on using Replication. + + +~> **NOTE:** Removing the `relicate_source` attribute from an existing RDS +Replicate database managed by Terraform will promote the database to a fully +standalone database. ## Attributes Reference @@ -88,3 +100,5 @@ The following attributes are exported: * `username` - The master username for the database * `storage_encrypted` - Specifies whether the DB instance is encrypted + +[1]: http://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/Overview.Replication.html From f346187948ce8e4dcb72bda05c3bf7c56bd1c00f Mon Sep 17 00:00:00 2001 From: Clint Shryock Date: Wed, 13 May 2015 16:36:30 -0500 Subject: [PATCH 2/6] provider/aws: Add RDS Read Replica support --- .../providers/aws/resource_aws_db_instance.go | 210 ++++++++++++------ .../aws/resource_aws_db_instance_test.go | 67 ++++++ 2 files changed, 212 insertions(+), 65 deletions(-) diff --git a/builtin/providers/aws/resource_aws_db_instance.go b/builtin/providers/aws/resource_aws_db_instance.go index 34e78184c680..5f865a72a70f 100644 --- a/builtin/providers/aws/resource_aws_db_instance.go +++ b/builtin/providers/aws/resource_aws_db_instance.go @@ -26,6 +26,7 @@ func resourceAwsDbInstance() *schema.Resource { "name": &schema.Schema{ Type: schema.TypeString, Optional: true, + Computed: true, ForceNew: true, }, @@ -89,6 +90,7 @@ func resourceAwsDbInstance() *schema.Resource { "backup_retention_period": &schema.Schema{ Type: schema.TypeInt, Optional: true, + Computed: true, Default: 1, }, @@ -191,6 +193,17 @@ func resourceAwsDbInstance() *schema.Resource { Computed: true, }, + "replicate_source_db": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + }, + + "replicas": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "tags": tagsSchema(), }, } @@ -199,87 +212,113 @@ func resourceAwsDbInstance() *schema.Resource { func resourceAwsDbInstanceCreate(d *schema.ResourceData, meta interface{}) error { conn := meta.(*AWSClient).rdsconn tags := tagsFromMapRDS(d.Get("tags").(map[string]interface{})) - opts := rds.CreateDBInstanceInput{ - AllocatedStorage: aws.Long(int64(d.Get("allocated_storage").(int))), - DBInstanceClass: aws.String(d.Get("instance_class").(string)), - DBInstanceIdentifier: aws.String(d.Get("identifier").(string)), - DBName: aws.String(d.Get("name").(string)), - MasterUsername: aws.String(d.Get("username").(string)), - MasterUserPassword: aws.String(d.Get("password").(string)), - Engine: aws.String(d.Get("engine").(string)), - EngineVersion: aws.String(d.Get("engine_version").(string)), - StorageEncrypted: aws.Boolean(d.Get("storage_encrypted").(bool)), - Tags: tags, - } - if attr, ok := d.GetOk("storage_type"); ok { - opts.StorageType = aws.String(attr.(string)) - } + if v, ok := d.GetOk("replicate_source_db"); ok { + opts := rds.CreateDBInstanceReadReplicaInput{ + SourceDBInstanceIdentifier: aws.String(v.(string)), + DBInstanceClass: aws.String(d.Get("instance_class").(string)), + DBInstanceIdentifier: aws.String(d.Get("identifier").(string)), + Tags: tags, + } + if attr, ok := d.GetOk("iops"); ok { + opts.IOPS = aws.Long(int64(attr.(int))) + } - attr := d.Get("backup_retention_period") - opts.BackupRetentionPeriod = aws.Long(int64(attr.(int))) + if attr, ok := d.GetOk("port"); ok { + opts.Port = aws.Long(int64(attr.(int))) + } - if attr, ok := d.GetOk("iops"); ok { - opts.IOPS = aws.Long(int64(attr.(int))) - } + if attr, ok := d.GetOk("availability_zone"); ok { + opts.AvailabilityZone = aws.String(attr.(string)) + } - if attr, ok := d.GetOk("port"); ok { - opts.Port = aws.Long(int64(attr.(int))) - } + if attr, ok := d.GetOk("publicly_accessible"); ok { + opts.PubliclyAccessible = aws.Boolean(attr.(bool)) + } + _, err := conn.CreateDBInstanceReadReplica(&opts) + if err != nil { + return fmt.Errorf("Error creating DB Instance: %s", err) + } + } else { + opts := rds.CreateDBInstanceInput{ + AllocatedStorage: aws.Long(int64(d.Get("allocated_storage").(int))), + DBName: aws.String(d.Get("name").(string)), + DBInstanceClass: aws.String(d.Get("instance_class").(string)), + DBInstanceIdentifier: aws.String(d.Get("identifier").(string)), + MasterUsername: aws.String(d.Get("username").(string)), + MasterUserPassword: aws.String(d.Get("password").(string)), + Engine: aws.String(d.Get("engine").(string)), + EngineVersion: aws.String(d.Get("engine_version").(string)), + StorageEncrypted: aws.Boolean(d.Get("storage_encrypted").(bool)), + Tags: tags, + } - if attr, ok := d.GetOk("multi_az"); ok { - opts.MultiAZ = aws.Boolean(attr.(bool)) - } + attr := d.Get("backup_retention_period") + opts.BackupRetentionPeriod = aws.Long(int64(attr.(int))) + if attr, ok := d.GetOk("multi_az"); ok { + opts.MultiAZ = aws.Boolean(attr.(bool)) + } - if attr, ok := d.GetOk("availability_zone"); ok { - opts.AvailabilityZone = aws.String(attr.(string)) - } + if attr, ok := d.GetOk("maintenance_window"); ok { + opts.PreferredMaintenanceWindow = aws.String(attr.(string)) + } - if attr, ok := d.GetOk("license_model"); ok { - opts.LicenseModel = aws.String(attr.(string)) - } + if attr, ok := d.GetOk("backup_window"); ok { + opts.PreferredBackupWindow = aws.String(attr.(string)) + } - if attr, ok := d.GetOk("maintenance_window"); ok { - opts.PreferredMaintenanceWindow = aws.String(attr.(string)) - } + if attr, ok := d.GetOk("license_model"); ok { + opts.LicenseModel = aws.String(attr.(string)) + } + if attr, ok := d.GetOk("parameter_group_name"); ok { + opts.DBParameterGroupName = aws.String(attr.(string)) + } - if attr, ok := d.GetOk("backup_window"); ok { - opts.PreferredBackupWindow = aws.String(attr.(string)) - } + if attr := d.Get("vpc_security_group_ids").(*schema.Set); attr.Len() > 0 { + var s []*string + for _, v := range attr.List() { + s = append(s, aws.String(v.(string))) + } + opts.VPCSecurityGroupIDs = s + } - if attr, ok := d.GetOk("publicly_accessible"); ok { - opts.PubliclyAccessible = aws.Boolean(attr.(bool)) - } + if attr := d.Get("security_group_names").(*schema.Set); attr.Len() > 0 { + var s []*string + for _, v := range attr.List() { + s = append(s, aws.String(v.(string))) + } + opts.DBSecurityGroups = s + } + if attr, ok := d.GetOk("storage_type"); ok { + opts.StorageType = aws.String(attr.(string)) + } - if attr, ok := d.GetOk("db_subnet_group_name"); ok { - opts.DBSubnetGroupName = aws.String(attr.(string)) - } + if attr, ok := d.GetOk("db_subnet_group_name"); ok { + opts.DBSubnetGroupName = aws.String(attr.(string)) + } - if attr, ok := d.GetOk("parameter_group_name"); ok { - opts.DBParameterGroupName = aws.String(attr.(string)) - } + if attr, ok := d.GetOk("iops"); ok { + opts.IOPS = aws.Long(int64(attr.(int))) + } - if attr := d.Get("vpc_security_group_ids").(*schema.Set); attr.Len() > 0 { - var s []*string - for _, v := range attr.List() { - s = append(s, aws.String(v.(string))) + if attr, ok := d.GetOk("port"); ok { + opts.Port = aws.Long(int64(attr.(int))) } - opts.VPCSecurityGroupIDs = s - } - if attr := d.Get("security_group_names").(*schema.Set); attr.Len() > 0 { - var s []*string - for _, v := range attr.List() { - s = append(s, aws.String(v.(string))) + if attr, ok := d.GetOk("availability_zone"); ok { + opts.AvailabilityZone = aws.String(attr.(string)) } - opts.DBSecurityGroups = s - } - log.Printf("[DEBUG] DB Instance create configuration: %#v", opts) - var err error - _, err = conn.CreateDBInstance(&opts) - if err != nil { - return fmt.Errorf("Error creating DB Instance: %s", err) + if attr, ok := d.GetOk("publicly_accessible"); ok { + opts.PubliclyAccessible = aws.Boolean(attr.(bool)) + } + + log.Printf("[DEBUG] DB Instance create configuration: %#v", opts) + var err error + _, err = conn.CreateDBInstance(&opts) + if err != nil { + return fmt.Errorf("Error creating DB Instance: %s", err) + } } d.SetId(d.Get("identifier").(string)) @@ -299,7 +338,7 @@ func resourceAwsDbInstanceCreate(d *schema.ResourceData, meta interface{}) error } // Wait, catching any errors - _, err = stateConf.WaitForState() + _, err := stateConf.WaitForState() if err != nil { return err } @@ -397,6 +436,23 @@ func resourceAwsDbInstanceRead(d *schema.ResourceData, meta interface{}) error { } d.Set("security_group_names", sgn) + // replica things + + var replicas []string + for _, v := range v.ReadReplicaDBInstanceIdentifiers { + replicas = append(replicas, *v) + } + if err := d.Set("replicas", replicas); err != nil { + return fmt.Errorf("[DEBUG] Error setting replicas attribute: %#v, error: %#v", replicas, err) + } + + if v.ReadReplicaSourceDBInstanceIdentifier != nil { + log.Printf("\n\n------\nread replica instance identifier: %#v", *v.ReadReplicaSourceDBInstanceIdentifier) + } else { + log.Printf("\n\n------\nno replica identifier") + } + d.Set("replicate_source_db", v.ReadReplicaSourceDBInstanceIdentifier) + return nil } @@ -438,6 +494,7 @@ func resourceAwsDbInstanceDelete(d *schema.ResourceData, meta interface{}) error } func resourceAwsDbInstanceUpdate(d *schema.ResourceData, meta interface{}) error { + log.Printf("\n\n-------- ENTER UPDATE -------\n\n") conn := meta.(*AWSClient).rdsconn d.Partial(true) @@ -536,6 +593,28 @@ func resourceAwsDbInstanceUpdate(d *schema.ResourceData, meta interface{}) error } } + // seperate request to promote a database + if d.HasChange("replicate_source_db") { + if d.Get("replicate_source_db").(string) == "" { + // promote + opts := rds.PromoteReadReplicaInput{ + DBInstanceIdentifier: aws.String(d.Id()), + } + attr := d.Get("backup_retention_period") + opts.BackupRetentionPeriod = aws.Long(int64(attr.(int))) + if attr, ok := d.GetOk("backup_window"); ok { + opts.PreferredBackupWindow = aws.String(attr.(string)) + } + _, err := conn.PromoteReadReplica(&opts) + if err != nil { + return fmt.Errorf("Error promoting database: %#v", err) + } + d.Set("replicate_source_db", "") + } else { + return fmt.Errorf("cannot elect new source database for replication") + } + } + if arn, err := buildRDSARN(d, meta); err == nil { if err := setTagsRDS(conn, d, arn); err != nil { return err @@ -544,6 +623,7 @@ func resourceAwsDbInstanceUpdate(d *schema.ResourceData, meta interface{}) error } } d.Partial(false) + log.Printf("\n\n-------- EXIT UPDATE -------\n\n") return resourceAwsDbInstanceRead(d, meta) } diff --git a/builtin/providers/aws/resource_aws_db_instance_test.go b/builtin/providers/aws/resource_aws_db_instance_test.go index 3b81817da1b0..b5ddf42a74c7 100644 --- a/builtin/providers/aws/resource_aws_db_instance_test.go +++ b/builtin/providers/aws/resource_aws_db_instance_test.go @@ -49,6 +49,35 @@ func TestAccAWSDBInstance(t *testing.T) { }) } +func TestAccAWSDBInstanceReplica(t *testing.T) { + // var v rds.DBInstance + var r rds.DBInstance + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testAccCheckAWSDBInstanceDestroy, + Steps: []resource.TestStep{ + // resource.TestStep{ + // Config: testAccAWSDBInstanceConfig, + // Check: resource.ComposeTestCheckFunc( + // testAccCheckAWSDBInstanceExists("aws_db_instance.bar", &v), + // ), + // }, + + resource.TestStep{ + Config: testAccAWSDBInstanceReplicaConfig, + Check: resource.ComposeTestCheckFunc( + testAccCheckAWSDBInstanceExists("aws_db_instance.replica", &r), + resource.TestCheckResourceAttr( + "aws_db_instance.replica", "replicate_source_db", "tf-update-more"), + testAccCheckAWSDBInstanceReplicaAttributes(&r), + ), + }, + }, + }) +} + func testAccCheckAWSDBInstanceDestroy(s *terraform.State) error { conn := testAccProvider.Meta().(*AWSClient).rdsconn @@ -103,6 +132,29 @@ func testAccCheckAWSDBInstanceAttributes(v *rds.DBInstance) resource.TestCheckFu } } +func testAccCheckAWSDBInstanceReplicaAttributes(r *rds.DBInstance) resource.TestCheckFunc { + return func(s *terraform.State) error { + + // if *v.Engine != "mysql" { + // return fmt.Errorf("bad engine: %#v", *v.Engine) + // } + + // if *v.EngineVersion != "5.6.21" { + // return fmt.Errorf("bad engine_version: %#v", *v.EngineVersion) + // } + + // if *v.BackupRetentionPeriod != 0 { + // return fmt.Errorf("bad backup_retention_period: %#v", *v.BackupRetentionPeriod) + // } + + if r.ReadReplicaSourceDBInstanceIdentifier != nil && *r.ReadReplicaSourceDBInstanceIdentifier != "tf-update-more" { + return fmt.Errorf("bad source identifier for replica, got: %#v, expected: 'tf-update-more'", *r.ReadReplicaSourceDBInstanceIdentifier) + } + + return nil + } +} + func testAccCheckAWSDBInstanceExists(n string, v *rds.DBInstance) resource.TestCheckFunc { return func(s *terraform.State) error { rs, ok := s.RootModule().Resources[n] @@ -156,3 +208,18 @@ resource "aws_db_instance" "bar" { parameter_group_name = "default.mysql5.6" }`, rand.New(rand.NewSource(time.Now().UnixNano())).Int()) + +var testAccAWSDBInstanceReplicaConfig = fmt.Sprintf(` +resource "aws_db_instance" "replica" { + identifier = "tf-replica-db-%d" + replicate_source_db = "tf-update-more" + allocated_storage = 5 + engine = "mysql" + engine_version = "5.6.19b" + instance_class = "db.t1.micro" + password = "fofofofxx" + username = "foo" + tags { + Name = "tf-replica-db" + } +}`, rand.New(rand.NewSource(time.Now().UnixNano())).Int()) From dc164c454e9dd9eab7b74ecf582a2e232ad9dc7d Mon Sep 17 00:00:00 2001 From: Clint Shryock Date: Wed, 13 May 2015 16:53:12 -0500 Subject: [PATCH 3/6] remove default here --- builtin/providers/aws/resource_aws_db_instance.go | 1 - 1 file changed, 1 deletion(-) diff --git a/builtin/providers/aws/resource_aws_db_instance.go b/builtin/providers/aws/resource_aws_db_instance.go index 5f865a72a70f..1372fcb05601 100644 --- a/builtin/providers/aws/resource_aws_db_instance.go +++ b/builtin/providers/aws/resource_aws_db_instance.go @@ -91,7 +91,6 @@ func resourceAwsDbInstance() *schema.Resource { Type: schema.TypeInt, Optional: true, Computed: true, - Default: 1, }, "backup_window": &schema.Schema{ From 6b6aa867c0c86eb21553c4ac67ae1626f2149da5 Mon Sep 17 00:00:00 2001 From: Clint Shryock Date: Wed, 20 May 2015 09:28:33 -0500 Subject: [PATCH 4/6] update read replica acceptance test --- .../providers/aws/resource_aws_db_instance.go | 4 + .../aws/resource_aws_db_instance_test.go | 83 +++++++++---------- 2 files changed, 45 insertions(+), 42 deletions(-) diff --git a/builtin/providers/aws/resource_aws_db_instance.go b/builtin/providers/aws/resource_aws_db_instance.go index 1372fcb05601..1901180982bf 100644 --- a/builtin/providers/aws/resource_aws_db_instance.go +++ b/builtin/providers/aws/resource_aws_db_instance.go @@ -670,6 +670,10 @@ func resourceAwsDbInstanceStateRefreshFunc( return nil, "", nil } + if v.DBInstanceStatus != nil { + log.Printf("[DEBUG] DB Instance status for instance %s: %s", d.Id(), *v.DBInstanceStatus) + } + return v, *v.DBInstanceStatus, nil } } diff --git a/builtin/providers/aws/resource_aws_db_instance_test.go b/builtin/providers/aws/resource_aws_db_instance_test.go index b5ddf42a74c7..707e65b4e8e5 100644 --- a/builtin/providers/aws/resource_aws_db_instance_test.go +++ b/builtin/providers/aws/resource_aws_db_instance_test.go @@ -50,28 +50,19 @@ func TestAccAWSDBInstance(t *testing.T) { } func TestAccAWSDBInstanceReplica(t *testing.T) { - // var v rds.DBInstance - var r rds.DBInstance + var s, r rds.DBInstance resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, Providers: testAccProviders, CheckDestroy: testAccCheckAWSDBInstanceDestroy, Steps: []resource.TestStep{ - // resource.TestStep{ - // Config: testAccAWSDBInstanceConfig, - // Check: resource.ComposeTestCheckFunc( - // testAccCheckAWSDBInstanceExists("aws_db_instance.bar", &v), - // ), - // }, - resource.TestStep{ - Config: testAccAWSDBInstanceReplicaConfig, + Config: testAccReplicaInstanceConfig(rand.New(rand.NewSource(time.Now().UnixNano())).Int()), Check: resource.ComposeTestCheckFunc( + testAccCheckAWSDBInstanceExists("aws_db_instance.bar", &s), testAccCheckAWSDBInstanceExists("aws_db_instance.replica", &r), - resource.TestCheckResourceAttr( - "aws_db_instance.replica", "replicate_source_db", "tf-update-more"), - testAccCheckAWSDBInstanceReplicaAttributes(&r), + testAccCheckAWSDBInstanceReplicaAttributes(&s, &r), ), }, }, @@ -132,23 +123,11 @@ func testAccCheckAWSDBInstanceAttributes(v *rds.DBInstance) resource.TestCheckFu } } -func testAccCheckAWSDBInstanceReplicaAttributes(r *rds.DBInstance) resource.TestCheckFunc { +func testAccCheckAWSDBInstanceReplicaAttributes(source, replica *rds.DBInstance) resource.TestCheckFunc { return func(s *terraform.State) error { - // if *v.Engine != "mysql" { - // return fmt.Errorf("bad engine: %#v", *v.Engine) - // } - - // if *v.EngineVersion != "5.6.21" { - // return fmt.Errorf("bad engine_version: %#v", *v.EngineVersion) - // } - - // if *v.BackupRetentionPeriod != 0 { - // return fmt.Errorf("bad backup_retention_period: %#v", *v.BackupRetentionPeriod) - // } - - if r.ReadReplicaSourceDBInstanceIdentifier != nil && *r.ReadReplicaSourceDBInstanceIdentifier != "tf-update-more" { - return fmt.Errorf("bad source identifier for replica, got: %#v, expected: 'tf-update-more'", *r.ReadReplicaSourceDBInstanceIdentifier) + if replica.ReadReplicaSourceDBInstanceIdentifier != nil && *replica.ReadReplicaSourceDBInstanceIdentifier != *source.DBInstanceIdentifier { + return fmt.Errorf("bad source identifier for replica, expected: '%s', got: '%s'", *source.DBInstanceIdentifier, *replica.ReadReplicaSourceDBInstanceIdentifier) } return nil @@ -209,17 +188,37 @@ resource "aws_db_instance" "bar" { parameter_group_name = "default.mysql5.6" }`, rand.New(rand.NewSource(time.Now().UnixNano())).Int()) -var testAccAWSDBInstanceReplicaConfig = fmt.Sprintf(` -resource "aws_db_instance" "replica" { - identifier = "tf-replica-db-%d" - replicate_source_db = "tf-update-more" - allocated_storage = 5 - engine = "mysql" - engine_version = "5.6.19b" - instance_class = "db.t1.micro" - password = "fofofofxx" - username = "foo" - tags { - Name = "tf-replica-db" - } -}`, rand.New(rand.NewSource(time.Now().UnixNano())).Int()) +func testAccReplicaInstanceConfig(val int) string { + return fmt.Sprintf(` + resource "aws_db_instance" "bar" { + identifier = "foobarbaz-test-terraform-%d" + + allocated_storage = 5 + engine = "mysql" + engine_version = "5.6.21" + instance_class = "db.t1.micro" + name = "baz" + password = "barbarbarbar" + username = "foo" + + backup_retention_period = 1 + + parameter_group_name = "default.mysql5.6" + } + + resource "aws_db_instance" "replica" { + identifier = "tf-replica-db-%d" + backup_retention_period = 0 + replicate_source_db = "${aws_db_instance.bar.identifier}" + allocated_storage = "${aws_db_instance.bar.allocated_storage}" + engine = "${aws_db_instance.bar.engine}" + engine_version = "${aws_db_instance.bar.engine_version}" + instance_class = "${aws_db_instance.bar.instance_class}" + password = "${aws_db_instance.bar.password}" + username = "${aws_db_instance.bar.username}" + tags { + Name = "tf-replica-db" + } + } + `, val, val) +} From 6de8f9d180a4bfba8ae551c4ba3e6b09357840ef Mon Sep 17 00:00:00 2001 From: Clint Shryock Date: Thu, 21 May 2015 09:49:46 -0500 Subject: [PATCH 5/6] provider/aws: RDS Read Replica cleanups remove typos, debugging, and try spelling things correctly --- builtin/providers/aws/resource_aws_db_instance.go | 7 ------- builtin/providers/aws/resource_aws_db_instance_test.go | 2 +- .../source/docs/providers/aws/r/db_instance.html.markdown | 4 ++-- 3 files changed, 3 insertions(+), 10 deletions(-) diff --git a/builtin/providers/aws/resource_aws_db_instance.go b/builtin/providers/aws/resource_aws_db_instance.go index 1901180982bf..c832c67bb682 100644 --- a/builtin/providers/aws/resource_aws_db_instance.go +++ b/builtin/providers/aws/resource_aws_db_instance.go @@ -445,11 +445,6 @@ func resourceAwsDbInstanceRead(d *schema.ResourceData, meta interface{}) error { return fmt.Errorf("[DEBUG] Error setting replicas attribute: %#v, error: %#v", replicas, err) } - if v.ReadReplicaSourceDBInstanceIdentifier != nil { - log.Printf("\n\n------\nread replica instance identifier: %#v", *v.ReadReplicaSourceDBInstanceIdentifier) - } else { - log.Printf("\n\n------\nno replica identifier") - } d.Set("replicate_source_db", v.ReadReplicaSourceDBInstanceIdentifier) return nil @@ -493,7 +488,6 @@ func resourceAwsDbInstanceDelete(d *schema.ResourceData, meta interface{}) error } func resourceAwsDbInstanceUpdate(d *schema.ResourceData, meta interface{}) error { - log.Printf("\n\n-------- ENTER UPDATE -------\n\n") conn := meta.(*AWSClient).rdsconn d.Partial(true) @@ -622,7 +616,6 @@ func resourceAwsDbInstanceUpdate(d *schema.ResourceData, meta interface{}) error } } d.Partial(false) - log.Printf("\n\n-------- EXIT UPDATE -------\n\n") return resourceAwsDbInstanceRead(d, meta) } diff --git a/builtin/providers/aws/resource_aws_db_instance_test.go b/builtin/providers/aws/resource_aws_db_instance_test.go index 707e65b4e8e5..b6d31f75e18b 100644 --- a/builtin/providers/aws/resource_aws_db_instance_test.go +++ b/builtin/providers/aws/resource_aws_db_instance_test.go @@ -209,7 +209,7 @@ func testAccReplicaInstanceConfig(val int) string { resource "aws_db_instance" "replica" { identifier = "tf-replica-db-%d" backup_retention_period = 0 - replicate_source_db = "${aws_db_instance.bar.identifier}" + replicate_source_db = "${aws_db_instance.bar.identifier}" allocated_storage = "${aws_db_instance.bar.allocated_storage}" engine = "${aws_db_instance.bar.engine}" engine_version = "${aws_db_instance.bar.engine_version}" diff --git a/website/source/docs/providers/aws/r/db_instance.html.markdown b/website/source/docs/providers/aws/r/db_instance.html.markdown index c536f8ee9ab1..c916705269e2 100644 --- a/website/source/docs/providers/aws/r/db_instance.html.markdown +++ b/website/source/docs/providers/aws/r/db_instance.html.markdown @@ -49,7 +49,7 @@ The following arguments are supported: * `username` - (Required) Username for the master DB user. * `availability_zone` - (Optional) The AZ for the RDS instance. * `backup_retention_period` - (Optional) The days to retain backups for. Must be -`1` or greater to be a source for a [Read Replicate][1]. +`1` or greater to be a source for a [Read Replica][1]. * `backup_window` - (Optional) The backup window. * `iops` - (Optional) The amount of provisioned IOPS. Setting this implies a storage_type of "io1". @@ -74,7 +74,7 @@ database, and to use this value as the source database. This correlates to the more information on using Replication. -~> **NOTE:** Removing the `relicate_source` attribute from an existing RDS +~> **NOTE:** Removing the `replicate_source` attribute from an existing RDS Replicate database managed by Terraform will promote the database to a fully standalone database. From 729238675b71a791e6f32dbc4b60873abd639721 Mon Sep 17 00:00:00 2001 From: Clint Shryock Date: Thu, 21 May 2015 15:06:22 -0500 Subject: [PATCH 6/6] update docs --- website/source/docs/providers/aws/r/db_instance.html.markdown | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/website/source/docs/providers/aws/r/db_instance.html.markdown b/website/source/docs/providers/aws/r/db_instance.html.markdown index c916705269e2..22e82a939c87 100644 --- a/website/source/docs/providers/aws/r/db_instance.html.markdown +++ b/website/source/docs/providers/aws/r/db_instance.html.markdown @@ -66,7 +66,7 @@ The following arguments are supported: * `apply_immediately` - (Optional) Specifies whether any database modifications are applied immediately, or during the next maintenance window. Default is `false`. See [Amazon RDS Documentation for more for more information.](http://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/Overview.DBInstance.Modifying.html) -* `replicate_source` - (Optional) Specifies that this resource is a Replicate +* `replicate_source_db` - (Optional) Specifies that this resource is a Replicate database, and to use this value as the source database. This correlates to the `identifier` of another Amazon RDS Database to replicate. See [DB Instance Replication][1] and @@ -74,7 +74,7 @@ database, and to use this value as the source database. This correlates to the more information on using Replication. -~> **NOTE:** Removing the `replicate_source` attribute from an existing RDS +~> **NOTE:** Removing the `replicate_source_db` attribute from an existing RDS Replicate database managed by Terraform will promote the database to a fully standalone database.