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 <krzysztof.wilczynski@linux.com>
pull/9677/head
Krzysztof Wilczynski 10 years ago committed by Paul Stack
parent 8abc6fcdf7
commit a078b893d6

@ -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())

@ -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))

@ -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.

Loading…
Cancel
Save