I have two VPCs in AWS. elasticache is in one of the VPC. I also have a lambda that needs to access the elasticache. I have attached the following policies to the lambda to access the elasticache.
AWSLambdaVPCAccessExecutionRole (as per mentioned here: https://docs.aws.amazon.com/lambda/latest/dg/vpc-ec-create-iam-role.html)
AmazonElastiCacheFullAccess
But I still cannot connect to the Elasticache endpoint from the lambda. It is throwing the following error:
Task timed out after 63.06 seconds
Essentially indicating it failed to connect. But any ec2 instance within the VPC can connect to the elasticache.
AWSLambdaVPCAccessExecutionRole
allows the Lambda to create an ENI to communicate with other resources in your VPC, but you need to configure your Lambda function within the VPC as well: docs.aws.amazon.com/lambda/latest/dg/vpc.html Also, worth noting, if you need to access non-VPC resources you will need to setup a NAT gateway – abigperson