provider/aws: Modifying the parameter_group_name of

aws_elasticache_replication_group caused a panic

Fixes #9097

The update for `parameter_group_name` was trying to find the incorrect
value to set `cache_parameter_group_name` - this is what was causing the
panic

```
% make testacc TEST=./builtin/providers/aws TESTARGS='-run=TestAccAWSElasticacheReplicationGroup_updateParameterGroup'
==> Checking that code complies with gofmt requirements...
go generate $(go list ./... | grep -v /terraform/vendor/)
2016/09/28 11:17:30 Generated command/internal_plugin_list.go
TF_ACC=1 go test ./builtin/providers/aws -v
-run=TestAccAWSElasticacheReplicationGroup_updateParameterGroup -timeout
120m
=== RUN   TestAccAWSElasticacheReplicationGroup_updateParameterGroup
--- PASS: TestAccAWSElasticacheReplicationGroup_updateParameterGroup
(903.90s)
PASS
ok      github.com/hashicorp/terraform/builtin/providers/aws903.931s
```
This commit is contained in:
stack72 2016-09-28 11:33:50 +01:00
parent 52761701e1
commit 2efd93a67e
No known key found for this signature in database
GPG Key ID: 8619A619B085CB16
2 changed files with 75 additions and 1 deletions

View File

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

View File

@ -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" {