From a078b893d664a586bf193e59e085bc9982aa5601 Mon Sep 17 00:00:00 2001 From: Krzysztof Wilczynski Date: Fri, 28 Oct 2016 00:08:14 +0100 Subject: [PATCH] Add support for `AutoMinorVersionUpgrade` to aws_elasticache_replication_group resource. (#9657) This commit adds an ability to modify the `AutoMinorVersionUpgrade` property of the Replication Group (which is enabled by default) accordingly. Signed-off-by: Krzysztof Wilczynski --- ...esource_aws_elasticache_replication_group.go | 17 +++++++++++++++++ ...ce_aws_elasticache_replication_group_test.go | 11 +++++++++++ .../elasticache_replication_group.html.markdown | 1 + 3 files changed, 29 insertions(+) diff --git a/builtin/providers/aws/resource_aws_elasticache_replication_group.go b/builtin/providers/aws/resource_aws_elasticache_replication_group.go index a5568b634..19cd9f1ba 100644 --- a/builtin/providers/aws/resource_aws_elasticache_replication_group.go +++ b/builtin/providers/aws/resource_aws_elasticache_replication_group.go @@ -31,6 +31,12 @@ func resourceAwsElasticacheReplicationGroup() *schema.Resource { Default: false, } + resourceSchema["auto_minor_version_upgrade"] = &schema.Schema{ + Type: schema.TypeBool, + Optional: true, + Default: true, + } + resourceSchema["replication_group_description"] = &schema.Schema{ Type: schema.TypeString, Required: true, @@ -78,6 +84,7 @@ func resourceAwsElasticacheReplicationGroupCreate(d *schema.ResourceData, meta i ReplicationGroupId: aws.String(d.Get("replication_group_id").(string)), ReplicationGroupDescription: aws.String(d.Get("replication_group_description").(string)), AutomaticFailoverEnabled: aws.Bool(d.Get("automatic_failover_enabled").(bool)), + AutoMinorVersionUpgrade: aws.Bool(d.Get("auto_minor_version_upgrade").(bool)), CacheNodeType: aws.String(d.Get("node_type").(string)), Engine: aws.String(d.Get("engine").(string)), Port: aws.Int64(int64(d.Get("port").(int))), @@ -237,12 +244,15 @@ func resourceAwsElasticacheReplicationGroupRead(d *schema.ResourceData, meta int d.Set("subnet_group_name", c.CacheSubnetGroupName) d.Set("security_group_names", flattenElastiCacheSecurityGroupNames(c.CacheSecurityGroups)) d.Set("security_group_ids", flattenElastiCacheSecurityGroupIds(c.SecurityGroups)) + if c.CacheParameterGroup != nil { d.Set("parameter_group_name", c.CacheParameterGroup.CacheParameterGroupName) } + d.Set("maintenance_window", c.PreferredMaintenanceWindow) d.Set("snapshot_window", rgp.SnapshotWindow) d.Set("snapshot_retention_limit", rgp.SnapshotRetentionLimit) + if rgp.ConfigurationEndpoint != nil { d.Set("port", rgp.ConfigurationEndpoint.Port) d.Set("configuration_endpoint_address", rgp.ConfigurationEndpoint.Address) @@ -250,6 +260,8 @@ func resourceAwsElasticacheReplicationGroupRead(d *schema.ResourceData, meta int d.Set("port", rgp.NodeGroups[0].PrimaryEndpoint.Port) d.Set("primary_endpoint_address", rgp.NodeGroups[0].PrimaryEndpoint.Address) } + + d.Set("auto_minor_version_upgrade", c.AutoMinorVersionUpgrade) } return nil @@ -274,6 +286,11 @@ func resourceAwsElasticacheReplicationGroupUpdate(d *schema.ResourceData, meta i requestUpdate = true } + if d.HasChange("auto_minor_version_upgrade") { + params.AutoMinorVersionUpgrade = aws.Bool(d.Get("auto_minor_version_upgrade").(bool)) + requestUpdate = true + } + if d.HasChange("security_group_ids") { if attr := d.Get("security_group_ids").(*schema.Set); attr.Len() > 0 { params.SecurityGroupIds = expandStringList(attr.List()) diff --git a/builtin/providers/aws/resource_aws_elasticache_replication_group_test.go b/builtin/providers/aws/resource_aws_elasticache_replication_group_test.go index 2a16c87be..8ba271f96 100644 --- a/builtin/providers/aws/resource_aws_elasticache_replication_group_test.go +++ b/builtin/providers/aws/resource_aws_elasticache_replication_group_test.go @@ -26,6 +26,8 @@ func TestAccAWSElasticacheReplicationGroup_basic(t *testing.T) { testAccCheckAWSElasticacheReplicationGroupExists("aws_elasticache_replication_group.bar", &rg), resource.TestCheckResourceAttr( "aws_elasticache_replication_group.bar", "number_cache_clusters", "2"), + resource.TestCheckResourceAttr( + "aws_elasticache_replication_group.bar", "auto_minor_version_upgrade", "false"), ), }, }, @@ -48,6 +50,8 @@ func TestAccAWSElasticacheReplicationGroup_updateDescription(t *testing.T) { "aws_elasticache_replication_group.bar", "number_cache_clusters", "2"), resource.TestCheckResourceAttr( "aws_elasticache_replication_group.bar", "replication_group_description", "test description"), + resource.TestCheckResourceAttr( + "aws_elasticache_replication_group.bar", "auto_minor_version_upgrade", "false"), ), }, @@ -59,6 +63,8 @@ func TestAccAWSElasticacheReplicationGroup_updateDescription(t *testing.T) { "aws_elasticache_replication_group.bar", "number_cache_clusters", "2"), resource.TestCheckResourceAttr( "aws_elasticache_replication_group.bar", "replication_group_description", "updated description"), + resource.TestCheckResourceAttr( + "aws_elasticache_replication_group.bar", "auto_minor_version_upgrade", "true"), ), }, }, @@ -141,6 +147,8 @@ func TestAccAWSElasticacheReplicationGroup_vpc(t *testing.T) { testAccCheckAWSElasticacheReplicationGroupExists("aws_elasticache_replication_group.bar", &rg), resource.TestCheckResourceAttr( "aws_elasticache_replication_group.bar", "number_cache_clusters", "1"), + resource.TestCheckResourceAttr( + "aws_elasticache_replication_group.bar", "auto_minor_version_upgrade", "false"), ), }, }, @@ -353,6 +361,7 @@ resource "aws_elasticache_replication_group" "bar" { parameter_group_name = "default.redis3.2" security_group_names = ["${aws_elasticache_security_group.bar.name}"] apply_immediately = true + auto_minor_version_upgrade = false }`, rName, rName, rName) } @@ -431,6 +440,7 @@ resource "aws_elasticache_replication_group" "bar" { parameter_group_name = "default.redis3.2" security_group_names = ["${aws_elasticache_security_group.bar.name}"] apply_immediately = true + auto_minor_version_upgrade = true }`, rName, rName, rName) } @@ -513,6 +523,7 @@ resource "aws_elasticache_replication_group" "bar" { security_group_ids = ["${aws_security_group.bar.id}"] parameter_group_name = "default.redis3.2" availability_zones = ["us-west-2a"] + auto_minor_version_upgrade = false } `, acctest.RandInt(), acctest.RandInt(), acctest.RandString(10)) diff --git a/website/source/docs/providers/aws/r/elasticache_replication_group.html.markdown b/website/source/docs/providers/aws/r/elasticache_replication_group.html.markdown index 8cfa96af5..6a247cfa9 100644 --- a/website/source/docs/providers/aws/r/elasticache_replication_group.html.markdown +++ b/website/source/docs/providers/aws/r/elasticache_replication_group.html.markdown @@ -37,6 +37,7 @@ The following arguments are supported: If Multi-AZ is enabled , the value of this parameter must be at least 2. Changing this number will force a new resource * `node_type` - (Required) The compute and memory capacity of the nodes in the node group. * `automatic_failover_enabled` - (Optional) Specifies whether a read-only replica will be automatically promoted to read/write primary if the existing primary fails. Defaults to `false`. +* `auto_minor_version_upgrade` - (Optional) Specifies whether a minor engine upgrades will be applied automatically to the underlying Cache Cluster instances during the maintenance window. Defaults to `true`. * `availability_zones` - (Optional) A list of EC2 availability zones in which the replication group's cache clusters will be created. The order of the availability zones in the list is not important. * `engine_version` - (Optional) The version number of the cache engine to be used for the cache clusters in this replication group. * `parameter_group_name` - (Optional) The name of the parameter group to associate with this replication group. If this argument is omitted, the default cache parameter group for the specified engine is used.