How to connect my Nodejs Lambda to a Serverless Elasticache running memcached distribution

81 views Asked by At

I have deployed Serverless Elasticache running Memcached Engine inside my VPC. I want my Nodejs Lambda inside my VPC to GET/SET values from this Elasticache. Since Serverless Elasticache comes with in-transit Encryption enabled by default, how can I connect my lambda to this TLS enable Elasticache? I was able to connect to my Elasticache from EC2 running inside same VPC through openssl s_client -connect ELASTICACHE_ENDPOINT:PORT command. I used memcache-plus NPM module to connect, but recieving connection error. Do my Lambda require client_cert.pem to access AWS managed Cache? If so how to include certs in my lambda?

This is my memcache-plus code:

const MemcachePlus = require('memcache-plus');
const client = new MemcachePlus({
   hosts: [process.env.ELASTICACHE_ENDPOINT],
   autodiscover: true,
   onNetError: function (err) {
     console.error(err);
   },
 });

How to add TLS Certs if required? Or is there any way without certificates?

P.S All my Security Groups for Lambda, Elasticache are configured correctly & Lambda is in same private subnet as Elasticache

I tried including tls : {} with no options inside memcache client initialisation, don't how to include certs inside lambda, if required.

0

There are 0 answers