Hi,
I'm looking to pass the DNS address of each elasticache node to my AWS webservers but am not sure of the best approach.
One approach I'm trying is to write the node addresses into a config file using the EC2 metadata, something like this:
resource "template_file" "web-userdata" {
filename = "userdata/web.sh"
vars {
cache_node_1 = "${aws_elasticache_cluster.web.cache_nodes.0.address}"
cache_node_2 = "${aws_elasticache_cluster.web.cache_nodes.1.address}"
}
}
resource "aws_launch_configuration" "webserver" {
image_id = "${var.web_ami}"
instance_type = "t2.micro"
user_data = "${template_file.web-userdata.rendered}"
...
}
This works but seems ugly. Is there a way to avoid individually specifying each node address as template vars? I couldn't seem to pass a list of address, nor grab the a list attribute from the elasticache resource itself.
Is there a better way? Does elasticache work well with Consul (which I haven't looked into in detail yet)?
Aside: there also doesn't seem to be a resource attribute for the "configuration endpoint" address, which is another option although I don't want to use a custom memcache client.
Thanks in advance, David
One option is to use Elasticache exposes a "configuration endpoint"