I'm using serverless to create a lambda function using the nodejs template.
serverless.yml
. When I try to serverless invoke local -f functionName
, it always times out, so I have to deploy it to test it.
Is it possible to test this out locally with serverless
?
Elasticache is not directly accessible from outside AWS environment by default. According to their documentation, the service is designed to be accessed exclusively from within AWS. In your case, serverless invoke local
times out because the connection itself cannot be established and the lambda function times out. So you can't run invoke locally to test this connection the way you are trying to do.
To connect to Elasticache redis from your local machine, you can use a NAT instance in your public subnet and setup the security groups to open up the correct ports and enable IP forwarding to allow connection to your redis cache cluster. The steps are given here.
However, I would just install redis locally and use an environment variable to change the connection string to connect to local redis on local machine and the actual Elasticache cluster when running on lambda.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With