provider/aws: Add Support for maintenance_window and back_window to rds_cluster_instance (#13134)

* provider/aws: Add Support for maintenance_window and back_window to rds_cluster_instance

Fixes: #9489

```
% make testacc TEST=./builtin/providers/aws TESTARGS='-run=TestAccAWSRDSClusterInstance_basic'
==> Checking that code complies with gofmt requirements...
go generate $(go list ./... | grep -v /terraform/vendor/)
2017/03/28 23:08:45 Generated command/internal_plugin_list.go
TF_ACC=1 go test ./builtin/providers/aws -v -run=TestAccAWSRDSClusterInstance_basic -timeout 120m
=== RUN   TestAccAWSRDSClusterInstance_basic
--- PASS: TestAccAWSRDSClusterInstance_basic (1433.41s)
PASS
ok  	github.com/hashicorp/terraform/builtin/providers/aws	1433.438s
```

* Update rds_cluster_instance.html.markdown

* Update rds_cluster_instance.html.markdown
This commit is contained in:
Paul Stack 2017-03-29 12:44:44 +03:00 committed by GitHub
parent 6c967d95b9
commit f44f0d8c86
3 changed files with 51 additions and 1 deletions

View File

@ -3,6 +3,7 @@ package aws
import (
"fmt"
"log"
"strings"
"time"
"github.com/aws/aws-sdk-go/aws"
@ -105,6 +106,27 @@ func resourceAwsRDSClusterInstance() *schema.Resource {
Computed: true,
},
"preferred_maintenance_window": {
Type: schema.TypeString,
Optional: true,
Computed: true,
StateFunc: func(v interface{}) string {
if v != nil {
value := v.(string)
return strings.ToLower(value)
}
return ""
},
ValidateFunc: validateOnceAWeekWindowFormat,
},
"preferred_backup_window": {
Type: schema.TypeString,
Optional: true,
Computed: true,
ValidateFunc: validateOnceADayWindowFormat,
},
"monitoring_interval": {
Type: schema.TypeInt,
Optional: true,
@ -154,6 +176,14 @@ func resourceAwsRDSClusterInstanceCreate(d *schema.ResourceData, meta interface{
createOpts.MonitoringRoleArn = aws.String(attr.(string))
}
if attr, ok := d.GetOk("preferred_backup_window"); ok {
createOpts.PreferredBackupWindow = aws.String(attr.(string))
}
if attr, ok := d.GetOk("preferred_maintenance_window"); ok {
createOpts.PreferredMaintenanceWindow = aws.String(attr.(string))
}
if attr, ok := d.GetOk("monitoring_interval"); ok {
createOpts.MonitoringInterval = aws.Int64(int64(attr.(int)))
}
@ -239,6 +269,8 @@ func resourceAwsRDSClusterInstanceRead(d *schema.ResourceData, meta interface{})
d.Set("kms_key_id", db.KmsKeyId)
d.Set("auto_minor_version_upgrade", db.AutoMinorVersionUpgrade)
d.Set("promotion_tier", db.PromotionTier)
d.Set("preferred_backup_window", db.PreferredBackupWindow)
d.Set("preferred_maintenance_window", db.PreferredMaintenanceWindow)
if db.MonitoringInterval != nil {
d.Set("monitoring_interval", db.MonitoringInterval)
@ -290,6 +322,18 @@ func resourceAwsRDSClusterInstanceUpdate(d *schema.ResourceData, meta interface{
requestUpdate = true
}
if d.HasChange("preferred_backup_window") {
d.SetPartial("preferred_backup_window")
req.PreferredBackupWindow = aws.String(d.Get("preferred_backup_window").(string))
requestUpdate = true
}
if d.HasChange("preferred_maintenance_window") {
d.SetPartial("preferred_maintenance_window")
req.PreferredMaintenanceWindow = aws.String(d.Get("preferred_maintenance_window").(string))
requestUpdate = true
}
if d.HasChange("monitoring_interval") {
d.SetPartial("monitoring_interval")
req.MonitoringInterval = aws.Int64(int64(d.Get("monitoring_interval").(int)))

View File

@ -30,6 +30,8 @@ func TestAccAWSRDSClusterInstance_basic(t *testing.T) {
testAccCheckAWSClusterInstanceExists("aws_rds_cluster_instance.cluster_instances", &v),
testAccCheckAWSDBClusterInstanceAttributes(&v),
resource.TestCheckResourceAttr("aws_rds_cluster_instance.cluster_instances", "auto_minor_version_upgrade", "true"),
resource.TestCheckResourceAttrSet("aws_rds_cluster_instance.cluster_instances", "preferred_maintenance_window"),
resource.TestCheckResourceAttrSet("aws_rds_cluster_instance.cluster_instances", "preferred_backup_window"),
),
},
{

View File

@ -70,7 +70,11 @@ 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
* `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.
* `preferred_backup_window` - (Optional) The daily time range during which automated backups are created if automated backups are enabled.
Eg: "04:00-09:00"
* `preferred_maintenance_window` - (Optional) The window to perform maintenance in.
Syntax: "ddd:hh24:mi-ddd:hh24:mi". Eg: "Mon:00:00-Mon:03:00".
* `tags` - (Optional) A mapping of tags to assign to the instance.
## Attributes Reference