From 029f1fa57236208a4cc77ddc330ea356500955bf Mon Sep 17 00:00:00 2001 From: stack72 Date: Wed, 16 Sep 2015 13:06:54 +0100 Subject: [PATCH 1/2] Adding configuration endpoint to the elasticache cluster nodes --- builtin/providers/aws/resource_aws_elasticache_cluster.go | 6 ++++++ .../docs/providers/aws/r/elasticache_cluster.html.markdown | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/builtin/providers/aws/resource_aws_elasticache_cluster.go b/builtin/providers/aws/resource_aws_elasticache_cluster.go index 080c56ac9..fc72f3a1d 100644 --- a/builtin/providers/aws/resource_aws_elasticache_cluster.go +++ b/builtin/providers/aws/resource_aws_elasticache_cluster.go @@ -105,6 +105,10 @@ func resourceAwsElasticacheCluster() *schema.Resource { Type: schema.TypeInt, Computed: true, }, + "configuration_endpoint": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, }, }, }, @@ -233,6 +237,7 @@ func resourceAwsElasticacheClusterRead(d *schema.ResourceData, meta interface{}) if c.ConfigurationEndpoint != nil { d.Set("port", c.ConfigurationEndpoint.Port) } + d.Set("subnet_group_name", c.CacheSubnetGroupName) d.Set("security_group_names", c.CacheSecurityGroups) d.Set("security_group_ids", c.SecurityGroups) @@ -353,6 +358,7 @@ func setCacheNodeData(d *schema.ResourceData, c *elasticache.CacheCluster) error "id": *node.CacheNodeId, "address": *node.Endpoint.Address, "port": int(*node.Endpoint.Port), + "configuration_endpoint": fmt.Sprintf("%s:%d", *node.Endpoint.Address, *node.Endpoint.Port), }) } diff --git a/website/source/docs/providers/aws/r/elasticache_cluster.html.markdown b/website/source/docs/providers/aws/r/elasticache_cluster.html.markdown index 953b78a9c..2e020a43d 100644 --- a/website/source/docs/providers/aws/r/elasticache_cluster.html.markdown +++ b/website/source/docs/providers/aws/r/elasticache_cluster.html.markdown @@ -80,7 +80,7 @@ Example: `arn:aws:s3:::my_bucket/snapshot1.rdb` The following attributes are exported: -* `cache_nodes` - List of node objects including `id`, `address` and `port`. +* `cache_nodes` - List of node objects including `id`, `address`, `port` and `configuration_endpoint`. Referenceable e.g. as `${aws_elasticache_cluster.bar.cache_nodes.0.address}` [1]: http://docs.aws.amazon.com/AmazonElastiCache/latest/APIReference/API_ModifyCacheCluster.html From 68c187c01ef59fd99b8f657b71e1ed2a8b2a6b6d Mon Sep 17 00:00:00 2001 From: stack72 Date: Wed, 16 Sep 2015 17:15:31 +0100 Subject: [PATCH 2/2] Changing the ElastiCache Cluster configuration_engine to be on the cluster, not on the cache nodes --- .../providers/aws/resource_aws_elasticache_cluster.go | 10 +++++----- .../providers/aws/r/elasticache_cluster.html.markdown | 4 +++- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/builtin/providers/aws/resource_aws_elasticache_cluster.go b/builtin/providers/aws/resource_aws_elasticache_cluster.go index fc72f3a1d..093ea88f8 100644 --- a/builtin/providers/aws/resource_aws_elasticache_cluster.go +++ b/builtin/providers/aws/resource_aws_elasticache_cluster.go @@ -29,6 +29,10 @@ func resourceAwsElasticacheCluster() *schema.Resource { Required: true, ForceNew: true, }, + "configuration_endpoint": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, "engine": &schema.Schema{ Type: schema.TypeString, Required: true, @@ -105,10 +109,6 @@ func resourceAwsElasticacheCluster() *schema.Resource { Type: schema.TypeInt, Computed: true, }, - "configuration_endpoint": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - }, }, }, }, @@ -236,6 +236,7 @@ func resourceAwsElasticacheClusterRead(d *schema.ResourceData, meta interface{}) d.Set("engine_version", c.EngineVersion) if c.ConfigurationEndpoint != nil { d.Set("port", c.ConfigurationEndpoint.Port) + d.Set("configuration_endpoint", aws.String(fmt.Sprintf("%s:%d", *c.ConfigurationEndpoint.Address, *c.ConfigurationEndpoint.Port))) } d.Set("subnet_group_name", c.CacheSubnetGroupName) @@ -358,7 +359,6 @@ func setCacheNodeData(d *schema.ResourceData, c *elasticache.CacheCluster) error "id": *node.CacheNodeId, "address": *node.Endpoint.Address, "port": int(*node.Endpoint.Port), - "configuration_endpoint": fmt.Sprintf("%s:%d", *node.Endpoint.Address, *node.Endpoint.Port), }) } diff --git a/website/source/docs/providers/aws/r/elasticache_cluster.html.markdown b/website/source/docs/providers/aws/r/elasticache_cluster.html.markdown index 2e020a43d..2fe6a8dcf 100644 --- a/website/source/docs/providers/aws/r/elasticache_cluster.html.markdown +++ b/website/source/docs/providers/aws/r/elasticache_cluster.html.markdown @@ -80,7 +80,9 @@ Example: `arn:aws:s3:::my_bucket/snapshot1.rdb` The following attributes are exported: -* `cache_nodes` - List of node objects including `id`, `address`, `port` and `configuration_endpoint`. +* `cache_nodes` - List of node objects including `id`, `address` and `port`. Referenceable e.g. as `${aws_elasticache_cluster.bar.cache_nodes.0.address}` + +* `configuration_endpoint` - (Memcached only) The configuration endpoint to allow host discovery [1]: http://docs.aws.amazon.com/AmazonElastiCache/latest/APIReference/API_ModifyCacheCluster.html