2
votes

I am having issues connecting Elasticache from a Lambda function I have done the following:

  1. Created a new security group
  2. Assign security group to Lambda and assigned two private subnets of same VPC
  3. Created an Elasticache redis cluster and assigned the above security group
  4. Created a NAT gateway address, assigned and ElasticIP (for the above VPC)

Internet works and I verified this by opening stackoverflow.com URL. However Elasticache auto discovery times out. Is there any additional configuration that needs to be done?

Update I added inbound rule for Security Group to port 6379 and now still times out.

1
Please check SG inbound/outbound, Lambda RoleTonyVo
The security group has no rules for inbound and 0.0.0.0/0 for outbound. And the lambda has Full access for both VPC and Elasticache. Is this correctvettipayyan
Does your lambda role has vpc execution role policy? Is your lambda is running in the same subnet as redis cluster? If different subnet, then correct routes should exists as well.Rishikesh Darandale
Also, I see that same security group is used for lambda and redis cluster, i hope that outbound traffic for lambda is correctly configured.Rishikesh Darandale
@RishikeshDarandaleYes, lambda has VPCExecutionRule. Did you mean outbound traffic for the NAT gateway? And in Redis cluster, i can only see "subnet group" and not individual subnets. And the subnet group there is the VPC which i used for both Lambda and Redis cluster.vettipayyan

1 Answers

0
votes

You will need to attach an IAM policy to the Lambda execution role that grants it the appropriate access permission to ElastiCache. If you are restricting access you will also need to check the VPC setting of the Lambda function and make sure it has the ability to access the subnet the EC cluster is located.

Take a look at the following article for specifics:

https://docs.aws.amazon.com/lambda/latest/dg/services-elasticache-tutorial.html