My goal is to obtain an object of Cache Cluster in the lambda to use the host endpoint.
// import { ElastiCacheClient, DescribeCacheClusterCommand } from '@aws-cdk/client-elasticache'
To achieve this, I’m using
const client = new ElastiCacheClient({ region });
const command = DescribeCacheClusterCommand({ CacheClusterId: MyId });
However the lambda times out at this point: const response = await client.send(command);
I have checked multiple times:
There are outbound rules from the lambda to the security groups of the cache cluster – done.
There are inbound rules in the cache cluster for the security groups of my lambda – done.
They are both in the same VPC – done.
I have given the necessary permissions for ["elasticache:DescribeCacheClusters", "elasticache:List*"]
– done.
Even if I make a direct request from the lambda to the cache cluster, it works fine:
const redisClient = redis.createClient({ url: myUrl, username: username, password: password, socket: { tls: true } });
await redisClient.connect();
const response = await redisClient.set("key", "value");
console.log({ response }); // => OK
await redisClient.disconnect();
I don’t understand what I am missing.
P.S. I can’t icrease lambda’s time out because of some restrictions.
I use these docs to adjust DescribeCacheClustersCommand and ElastiCache policy
I’m expecting DescribeCacheClusterCommand
returns a cluster object.