# Elasticache(redis) cluster mode access issues

**URL:** <https://discuss.hashicorp.com/t/elasticache-redis-cluster-mode-access-issues/66294>\
**Category:** Boundary\
**Created:** [April 23, 2024, 1:26pm UTC](https://discuss.hashicorp.com/t/elasticache-redis-cluster-mode-access-issues/66294 "2024-04-23T13:26:41Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![dmitryroshchin](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/dmitryroshchin/32/34564_2.png) [@dmitryroshchin](https://discuss.hashicorp.com/u/dmitryroshchin)\
**Post date:** [April 23, 2024, 1:26pm UTC](https://discuss.hashicorp.com/t/elasticache-redis-cluster-mode-access-issues/66294/1 "2024-04-23T13:26:41Z")

</div>

Hey, folks!

We’ve set up boundary for secure connections to our elasticcache multinode clusters.  
Boundary target hosts are aws elasticcache(redis) [configuration endpoints](https://docs.aws.amazon.com/AmazonElastiCache/latest/red-ug/Endpoints.html)  
Keys are distributed among different nodes, there is no node which stores all the keys in a cluster.  
Tunnel is accessible on localhost port 7000, direct access to elasticcache is restricted by security groups.  
When we connect to configuration endpoint and try to get sample redis keys, most of the time I get errors like:

MOVED 10116 [redis7-prodlike-eu-central-1-redis-0002-001.redis7-prodlike-eu-central-1-redis.3gcxfr.euc1.cache.amazonaws.com:7000](http://redis7-prodlike-eu-central-1-redis-0002-001.redis7-prodlike-eu-central-1-redis.3gcxfr.euc1.cache.amazonaws.com:7000)

But sometimes I get the key value back.  
Seems like this it depends to the result on configuration endpoint DNS resolution. Here is sample of two different responses on the same command via boundary tunnel:

REQUEST:  
`redis-cli --tls -h localhost -a PASS -p 7000 --user USER get mykey23`  
RESPONSE:  
`MOVED 10116 redis7-prodlike-eu-central-1-redis-0002-001.redis7-prodlike-eu-central-1-redis.3gcxfr.euc1.cache.amazonaws.com:7000`

NEXT REQUEST:  
`redis-cli --tls -h localhost -a PASS -p 7000 --user USER get mykey23`  
NEXT RESPONSE:  
`"Hello22"`

Using redis-cli with -c flag is not an option for us, because it tries direct access to nodes while following redirect, and we have tunnel to only one(via configuration endpoint fqdn) on localhost  
There is an option to create target with hostset that include every nodes, but this will still require manual switching between targets.

Here is the same problem in goteleport:

> <https://github.com/gravitational/teleport/issues/22992>
>
> \### Expected behavior:
> 
> When accessing a redis cluster behind Teleport, someti…mes it will get a redis MOVED redirection. Since the end user's client is interacting with Teleport's redis service, and can't follow the redirect to directly access the cluster node, Teleport should handle making the request to the other node instead.
> 
> See: https://redis.io/docs/reference/cluster-spec/#moved-redirection
> 
> \### Current behavior:
> 
> The end user's redis client will get a moved redirection response back from redis and fail to connect to the real redis cluster node referenced.
> 
> Ideally, the end-user should not need to include -c at all since Teleport's db service should transparently handle those responses.
> 
> \### Bug details:
> \- Teleport version - 
> \- Recreation steps - To recreate, set up a Redis cluster (elisticache works for this) with more than one redis node. Set up db access. Connect via \`tsh proxy db\` and include the \`-c\` option when launching redis-cli to enable redirect handling.
> \- Debug logs -

The root of the problem is in how redis clients work with clusters, it needs direct access to every node and nodes redirect clients to other nodes when the don have requested key.  
The protocol itself seems to be bastion unfriendly

So, the question is - Is there any recommended schemes/guides for accessing elasticcache clusters via boundary?  
Or maybe somebody already dealt with the issue? I’d be grateful for any advice

---

<div class="post-metadata">

**Author:** ![jeff](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/jeff/32/12882_2.png) [@jeff](https://discuss.hashicorp.com/u/jeff)\
**Post date:** [May 2, 2024, 3:11pm UTC](https://discuss.hashicorp.com/t/elasticache-redis-cluster-mode-access-issues/66294/2 "2024-05-02T15:11:02Z")

</div>

Hello,

We don’t have a particular solution for this yet, although something coming down the pipeline later may well help. It does seem to be in large part the protocol being bastion unfriendly as you said; in Vault we transparently forward requests from standby nodes to the active node and return the results as necessary to make it LB/bastion friendly but that is something that would have to be implemented within Redis :-/
