AWS Lambda connection timeout to Elasticache
I ran into this issue as well, but with Python. For me, there were a few problems that had to be ironed out
- The lambda needs VPC permissions.
- The ElastiCache security group needs an inbound rule from the Lambda security group that allows communication on the Redis port. I thought they could just be in the same security group.
- And the real kicker: I had turned on encryption in-transit. This meant that I needed to pass
redis.RedisClient(... ssl=True)
. The redis-py page mentions thatssl_cert_reqs
needs to be set toNone
for use with ElastiCache, but that didn't seem to be true in my case. I did however need to passssl=True
.
It makes sense that ssl=True
needed to be set but the connection was just timing out so I went round and round trying to figure out what the problem with the permissions/VPC/SG setup was.