provider/aws: aws_elasticache_cluster normalizes name to lowercase

This commit is contained in:
thrashr888 2015-09-14 16:50:53 -07:00
parent 57bea9f26c
commit 55f3c8c764
3 changed files with 17 additions and 4 deletions

View File

@ -28,6 +28,12 @@ func resourceAwsElasticacheCluster() *schema.Resource {
Type: schema.TypeString,
Required: true,
ForceNew: true,
StateFunc: func(val interface{}) string {
// Elasticache normalizes cluster ids to lowercase,
// so we have to do this too or else we can end up
// with non-converging diffs.
return strings.ToLower(val.(string))
},
},
"engine": &schema.Schema{
Type: schema.TypeString,
@ -190,7 +196,11 @@ func resourceAwsElasticacheClusterCreate(d *schema.ResourceData, meta interface{
return fmt.Errorf("Error creating Elasticache: %s", err)
}
d.SetId(*resp.CacheCluster.CacheClusterId)
// Assign the cluster id as the resource ID
// Elasticache always retains the id 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(*resp.CacheCluster.CacheClusterId))
pending := []string{"creating"}
stateConf := &resource.StateChangeConf{

View File

@ -163,7 +163,10 @@ resource "aws_security_group" "bar" {
}
resource "aws_elasticache_cluster" "bar" {
cluster_id = "tf-test-%03d"
// Including uppercase letters in this name to ensure
// that we correctly handle the fact that the API
// normalizes names to lowercase.
cluster_id = "tf-TEST-%03d"
node_type = "cache.m1.small"
num_cache_nodes = 1
engine = "redis"

View File

@ -27,8 +27,8 @@ resource "aws_elasticache_cluster" "bar" {
The following arguments are supported:
* `cluster_id` (Required) Group identifier. This parameter is stored as a
lowercase string
* `cluster_id` (Required) Group identifier. Elasticache converts
this name to lowercase
* `engine` (Required) Name of the cache engine to be used for this cache cluster.
Valid values for this parameter are `memcached` or `redis`