Skip to content

Commit

Permalink
add Aurora instance failover priority feature (#8087)
Browse files Browse the repository at this point in the history
* add Aurora instance failover priority feature

* promotion_tier move to input directly

* fix format issue
  • Loading branch information
arcadiatea authored and stack72 committed Aug 11, 2016
1 parent c9468ef commit 45c5675
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
14 changes: 14 additions & 0 deletions builtin/providers/aws/resource_aws_rds_cluster_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,12 @@ func resourceAwsRDSClusterInstance() *schema.Resource {
Default: 0,
},

"promotion_tier": &schema.Schema{
Type: schema.TypeInt,
Optional: true,
Default: 0,
},

"tags": tagsSchema(),
},
}
Expand All @@ -123,6 +129,7 @@ func resourceAwsRDSClusterInstanceCreate(d *schema.ResourceData, meta interface{
DBClusterIdentifier: aws.String(d.Get("cluster_identifier").(string)),
Engine: aws.String("aurora"),
PubliclyAccessible: aws.Bool(d.Get("publicly_accessible").(bool)),
PromotionTier: aws.Int64(int64(d.Get("promotion_tier").(int))),
Tags: tags,
}

Expand Down Expand Up @@ -226,6 +233,7 @@ func resourceAwsRDSClusterInstanceRead(d *schema.ResourceData, meta interface{})
d.Set("instance_class", db.DBInstanceClass)
d.Set("identifier", db.DBInstanceIdentifier)
d.Set("storage_encrypted", db.StorageEncrypted)
d.Set("promotion_tier", db.PromotionTier)

if db.MonitoringInterval != nil {
d.Set("monitoring_interval", db.MonitoringInterval)
Expand Down Expand Up @@ -285,6 +293,12 @@ func resourceAwsRDSClusterInstanceUpdate(d *schema.ResourceData, meta interface{
requestUpdate = true
}

if d.HasChange("promotion_tier") {
d.SetPartial("promotion_tier")
req.PromotionTier = aws.Int64(int64(d.Get("promotion_tier").(int)))
requestUpdate = true
}

log.Printf("[DEBUG] Send DB Instance Modification request: %#v", requestUpdate)
if requestUpdate {
log.Printf("[DEBUG] DB Instance Modification request: %#v", req)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@ resource "aws_rds_cluster_instance" "cluster_instances" {
cluster_identifier = "${aws_rds_cluster.default.id}"
instance_class = "db.r3.large"
db_parameter_group_name = "${aws_db_parameter_group.bar.name}"
promotion_tier = "3"
}
resource "aws_db_parameter_group" "bar" {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ details on controlling this property.
enhanced monitoring metrics to CloudWatch Logs. You can find more information on the [AWS Documentation](http://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/USER_Monitoring.html)
what IAM permissions are needed to allow Enhanced Monitoring for RDS Instances.
* `monitoring_interval` - (Optional) The interval, in seconds, between points when Enhanced Monitoring metrics are collected for the DB instance. To disable collecting Enhanced Monitoring metrics, specify 0. The default is 0. Valid Values: 0, 1, 5, 10, 15, 30, 60.
* `promotion_tier` - (Optional) Default 0. Failover Priority setting on instance level. The reader who has lower tier has higher priority to get promoter to writer
* `kms_key_id` - (Optional) The ARN for the KMS encryption key. When specifying `kms_key_id`, `storage_encrypted` needs to be set to true
* `tags` - (Optional) A mapping of tags to assign to the instance.

Expand Down

0 comments on commit 45c5675

Please sign in to comment.