Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can you connect to Amazon ElastiСache Redis outside of Amazon?

I'm able to connect to an ElastiCache Redis instance in a VPC from EC2 instances. But I would like to know if there is a way to connect to an ElastiCache Redis node outside of Amazon EC2 instances, such as from my local dev setup or VPS instances provided by other vendors.

Currently when trying from my local set up:

redis-cli -h my-node-endpoint -p 6379 

I only get a timeout after some time.

like image 855
Loic Duros Avatar asked Feb 20 '14 19:02

Loic Duros


People also ask

How do I connect to AWS Redis cluster from local machine?

Sign in to the AWS Management Console and open the ElastiCache console at https://console.aws.amazon.com/elasticache/ . From the navigation pane, choose Redis clusters. The clusters screen will appear with a list of Redis (cluster mode disabled) and Redis (cluster mode enabled) clusters.

Is ElastiCache publicly accessible?

Opening up the ElastiCache cluster to 0.0. 0.0/0 does not expose the cluster to the Internet because it has no public IP address and therefore cannot be accessed from outside the VPC.

How do I make my AWS Redis public?

Create a Cloud9 instance in the same VPC as my Elasticache instance. Add a security group rule to the Elasticache instance to allow traffic from the Cloud9 instance security group. Run a tiny TCP proxy (written in Go) in the Cloud9 instance that proxies traffic to and from the Elasticache instance.


2 Answers

SSH port forwarding should do the trick. Try running this from you client.

ssh -f -N -L 6379:<your redis node endpoint>:6379 <your EC2 node that you use to connect to redis> 

Then from your client

redis-cli -h 127.0.0.1 -p 6379 

It works for me.

Please note that default port for redis is 6379 not 6739. And also make sure you allow the security group of the EC2 node that you are using to connect to your redis instance into your Cache security group.

Also, AWS now supports accessing your cluster more info here

like image 99
Rico Avatar answered Sep 27 '22 22:09

Rico


Update 2018

The previous answer was accurate when written, however it is now possible with some configuration to access redis cache from outside using the directions according to Accessing ElastiCache Resources from Outside AWS


Old Answer

No, you can't without resorting to 'tricks' such as a tunnel, which maybe OK for testing but will kill any real benefit of using a super-fast cache with the added latency/overhead.

The Old FAQ under How is using Amazon ElastiCache inside a VPC different from using it outside?:

An Amazon ElastiCache Cluster, inside or outside a VPC, is never allowed to be accessed from the Internet

However, this language has been removed in the current faq

like image 29
E.J. Brennan Avatar answered Sep 27 '22 22:09

E.J. Brennan