diff --git a/builtin/providers/aws/resource_aws_elasticache_replication_group.go b/builtin/providers/aws/resource_aws_elasticache_replication_group.go index 4bb42261a9..bcee8cf03c 100644 --- a/builtin/providers/aws/resource_aws_elasticache_replication_group.go +++ b/builtin/providers/aws/resource_aws_elasticache_replication_group.go @@ -275,7 +275,7 @@ func resourceAwsElasticacheReplicationGroupUpdate(d *schema.ResourceData, meta i } if d.HasChange("parameter_group_name") { - params.CacheParameterGroupName = aws.String(d.Get("cache_parameter_group_name").(string)) + params.CacheParameterGroupName = aws.String(d.Get("parameter_group_name").(string)) requestUpdate = true } 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 ebd3e6a9e3..58c872a235 100644 --- a/builtin/providers/aws/resource_aws_elasticache_replication_group_test.go +++ b/builtin/providers/aws/resource_aws_elasticache_replication_group_test.go @@ -98,6 +98,36 @@ func TestAccAWSElasticacheReplicationGroup_updateNodeSize(t *testing.T) { }) } +//This is a test to prove that we panic we get in https://github.com/hashicorp/terraform/issues/9097 +func TestAccAWSElasticacheReplicationGroup_updateParameterGroup(t *testing.T) { + var rg elasticache.ReplicationGroup + rName := acctest.RandString(10) + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testAccCheckAWSElasticacheReplicationDestroy, + Steps: []resource.TestStep{ + resource.TestStep{ + Config: testAccAWSElasticacheReplicationGroupConfig(rName), + Check: resource.ComposeTestCheckFunc( + testAccCheckAWSElasticacheReplicationGroupExists("aws_elasticache_replication_group.bar", &rg), + resource.TestCheckResourceAttr( + "aws_elasticache_replication_group.bar", "parameter_group_name", "default.redis2.8"), + ), + }, + + resource.TestStep{ + Config: testAccAWSElasticacheReplicationGroupConfigUpdatedParameterGroup(rName), + Check: resource.ComposeTestCheckFunc( + testAccCheckAWSElasticacheReplicationGroupExists("aws_elasticache_replication_group.bar", &rg), + resource.TestCheckResourceAttr( + "aws_elasticache_replication_group.bar", "parameter_group_name", "allkeys-lru"), + ), + }, + }, + }) +} + func TestAccAWSElasticacheReplicationGroup_vpc(t *testing.T) { var rg elasticache.ReplicationGroup resource.Test(t, resource.TestCase{ @@ -293,6 +323,50 @@ resource "aws_elasticache_replication_group" "bar" { }`, rName, rName, rName) } +func testAccAWSElasticacheReplicationGroupConfigUpdatedParameterGroup(rName string) string { + return fmt.Sprintf(` +provider "aws" { + region = "us-east-1" +} +resource "aws_security_group" "bar" { + name = "tf-test-security-group-%s" + description = "tf-test-security-group-descr" + ingress { + from_port = -1 + to_port = -1 + protocol = "icmp" + cidr_blocks = ["0.0.0.0/0"] + } +} + +resource "aws_elasticache_security_group" "bar" { + name = "tf-test-security-group-%s" + description = "tf-test-security-group-descr" + security_group_names = ["${aws_security_group.bar.name}"] +} + +resource "aws_elasticache_parameter_group" "bar" { + name = "allkeys-lru" + family = "redis2.8" + + parameter { + name = "maxmemory-policy" + value = "allkeys-lru" + } +} + +resource "aws_elasticache_replication_group" "bar" { + replication_group_id = "tf-%s" + replication_group_description = "test description" + node_type = "cache.m1.small" + number_cache_clusters = 2 + port = 6379 + parameter_group_name = "${aws_elasticache_parameter_group.bar.name}" + security_group_names = ["${aws_elasticache_security_group.bar.name}"] + apply_immediately = true +}`, rName, rName, rName) +} + func testAccAWSElasticacheReplicationGroupConfigUpdatedDescription(rName string) string { return fmt.Sprintf(` provider "aws" {