Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

aws_elasticache_subnet_group normalizes name to lowercase. #3120

Merged
merged 1 commit into from
Sep 4, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion builtin/providers/aws/resource_aws_elasticache_subnet_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package aws
import (
"fmt"
"log"
"strings"
"time"

"github.com/aws/aws-sdk-go/aws"
Expand All @@ -29,6 +30,12 @@ func resourceAwsElasticacheSubnetGroup() *schema.Resource {
Type: schema.TypeString,
Required: true,
ForceNew: true,
StateFunc: func(val interface{}) string {
// Elasticache normalizes subnet names to lowercase,
// so we have to do this too or else we can end up
// with non-converging diffs.
return strings.ToLower(val.(string))
},
},
"subnet_ids": &schema.Schema{
Type: schema.TypeSet,
Expand Down Expand Up @@ -66,7 +73,10 @@ func resourceAwsElasticacheSubnetGroupCreate(d *schema.ResourceData, meta interf
}

// Assign the group name as the resource ID
d.SetId(name)
// Elasticache always retains the name in lower case, so we have to
// mimic that or else we won't be able to refresh a resource whose
// name contained uppercase characters.
d.SetId(strings.ToLower(name))

return nil
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,10 @@ resource "aws_subnet" "foo" {
}

resource "aws_elasticache_subnet_group" "bar" {
name = "tf-test-cache-subnet-%03d"
// Including uppercase letters in this name to ensure
// that we correctly handle the fact that the API
// normalizes names to lowercase.
name = "tf-TEST-cache-subnet-%03d"
description = "tf-test-cache-subnet-group-descr"
subnet_ids = ["${aws_subnet.foo.id}"]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ resource "aws_elasticache_subnet_group" "bar" {
The following arguments are supported:

* `description` – (Required) Description for the cache subnet group
* `name` – (Required) Name for the cache subnet group. This value is stored as
a lowercase string
* `name` – (Required) Name for the cache subnet group. Elasticache converts
this name to lowercase.
* `subnet_ids` – (Required) List of VPC Subnet IDs for the cache subnet group

## Attributes Reference
Expand Down