How to connect to ElastiCache Redis

Arun Kumar
Cloud Techies
2 min readFeb 4, 2021

--

Rationale

If ElastiCache/Redis deployments default encryption for both inflight and at-rest, then this could cause issues with connectivity for some clients, like redis-cli.

Solution Summary

https://aws.amazon.com/premiumsupport/knowledge-center/elasticache-connect-redis-node/

Two parts:

  • Deploy EC2 for your app/branch and run stunnel to Redis (then use SSM to SSH into the server and run Redis commands from CLI)
  • Use SSM to port forward 2 x ports from your EC2 + stunnel setup to localhost, and connect with a desktop client.

Steps

# Using an ec2 I have an ec2 keypair for (app server):

# Find the instance ID based on Tag Name

# To connect to the EC2 to test connectivity

# — — — — — — — — — — — -
# On the EC2
# — — — — — — — — — — — -

# Test EC2 connectivity to redis is OK

# Setup stunnel as per -

# Install stunnel on ec2

# cat /etc/stunnel/redis-cli.conf

# Run stunnel (as root)

# Check if it’s up

# — — — — — — — — — — — -
# Back on the laptop
# — — — — — — — — — — — -

# Create 2 port forwarding tunnels for stunnel redis

# Now test from laptop

Final Output:

--

--

Arun Kumar
Cloud Techies

Cloud Architect | AWS, GCP, Azure, Python, Kubernetes, Terraform, Ansible