From 49a01ee787d752fd7fc27909e701262acff77a88 Mon Sep 17 00:00:00 2001 From: Clint Shryock Date: Tue, 7 Jul 2015 10:41:46 -0600 Subject: [PATCH] provider/aws: Add maintenance window to ElastiCache cluster Implements #2612 --- .../aws/resource_aws_elasticache_cluster.go | 15 +++++++++++++++ .../aws/r/elasticache_cluster.html.markdown | 4 ++++ 2 files changed, 19 insertions(+) diff --git a/builtin/providers/aws/resource_aws_elasticache_cluster.go b/builtin/providers/aws/resource_aws_elasticache_cluster.go index d47b275c7..fe2139e36 100644 --- a/builtin/providers/aws/resource_aws_elasticache_cluster.go +++ b/builtin/providers/aws/resource_aws_elasticache_cluster.go @@ -58,6 +58,11 @@ func resourceAwsElasticacheCluster() *schema.Resource { Optional: true, Computed: true, }, + "maintenance_window": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Computed: true, + }, "subnet_group_name": &schema.Schema{ Type: schema.TypeString, Optional: true, @@ -154,6 +159,10 @@ func resourceAwsElasticacheClusterCreate(d *schema.ResourceData, meta interface{ req.CacheParameterGroupName = aws.String(v.(string)) } + if v, ok := d.GetOk("maintenance_window"); ok { + req.PreferredMaintenanceWindow = aws.String(v.(string)) + } + _, err := conn.CreateCacheCluster(req) if err != nil { return fmt.Errorf("Error creating Elasticache: %s", err) @@ -206,6 +215,7 @@ func resourceAwsElasticacheClusterRead(d *schema.ResourceData, meta interface{}) d.Set("security_group_names", c.CacheSecurityGroups) d.Set("security_group_ids", c.SecurityGroups) d.Set("parameter_group_name", c.CacheParameterGroup) + d.Set("maintenance_window", c.PreferredMaintenanceWindow) if err := setCacheNodeData(d, c); err != nil { return err @@ -264,6 +274,11 @@ func resourceAwsElasticacheClusterUpdate(d *schema.ResourceData, meta interface{ requestUpdate = true } + if d.HasChange("maintenance_window") { + req.PreferredMaintenanceWindow = aws.String(d.Get("maintenance_window").(string)) + requestUpdate = true + } + if d.HasChange("engine_version") { req.EngineVersion = aws.String(d.Get("engine_version").(string)) requestUpdate = true diff --git a/website/source/docs/providers/aws/r/elasticache_cluster.html.markdown b/website/source/docs/providers/aws/r/elasticache_cluster.html.markdown index bbc52ac2c..d6787a143 100644 --- a/website/source/docs/providers/aws/r/elasticache_cluster.html.markdown +++ b/website/source/docs/providers/aws/r/elasticache_cluster.html.markdown @@ -37,6 +37,10 @@ lowercase string See [Selecting a Cache Engine and Version](http://docs.aws.amazon.com/AmazonElastiCache/latest/UserGuide/SelectEngine.html) in the AWS Documentation center for supported versions +* `maintenance_window` – (Optional) Specifies the weekly time range which maintenance +on the cache cluster is performed. The format is `ddd:hh24:mi-ddd:hh24:mi` (24H Clock UTC). +The minimum maintenance window is a 60 minute period. Example: `sun:05:00-sun:09:00` + * `node_type` – (Required) The compute and memory capacity of the nodes. See [Available Cache Node Types](http://aws.amazon.com/elasticache/details#Available_Cache_Node_Types) for supported node types