I am using go-redis library to use AWS MemoryDB cluster as a database.
I am able to connect to cluster with VPN connection, however
the following cli command connects to database:
redis-cli --tls -u redis://<memory-db-endpoint> -p 6379
but the following Go code does not work and get i/o timeout
error.
conf, err := redis.ParseURL("redis://$CLUSTER_ENDPOINT:6379")
if err != nil {
panic(err)
}
cl := redis.NewClient(conf)
res, err := cl.Ping(context.Background()).Result()
if err != nil {
panic(err)
}
what is needed to establish a connection with a single node AWS MemoryDB cluster?
2
Answers
The problem is
go-redis
library does not know how to get system certificates for TLS connections.So, here is how to pass system certificate pool to connection config.
Redis URIs with TLS must begin with "rediss://", not "redis://"; see https://www.iana.org/assignments/uri-schemes/prov/rediss for more information.
This code works: