In software engineering factoring, modularization, and donโt repeat yourself (DRY) are popular concepts. Documentation, however, can be a nightmare of jumping all over the place and missing steps to get something to work.
If youโre like me and you just want answers now, it can cause unnecessary toil having to bounce from article to article just to get something to work. I recently experienced this while helping a company connect their cloud functions to Redis. Googleโs documentation is pretty awesome and improving all the time, but sometimes those engineering principles of factoring make them difficult to follow.
Long story short, here are the steps below that work based on the example documentation.

Working cloud function connecting toย Redis
Of course you will want to replace the project ID and other variables at the top, but I hope this helps simplify getting your cloud functions interacting with Redis (Memorystore) using serverless VPC connector.
https://gist.github.com/mikesparr/8985378640242d8e453cc2212509814d
Cleanup
If you are just trying out Cloud Functions and Redis (Memorystore), then donโt forget to delete the resources you create to avoid unnecessary expenses. The simplest way is just to delete the project.
Below are the steps to reverse the example above just in case you need them.
https://gist.github.com/mikesparr/14f6a9aacc1f16908c5d851249776992
Enjoy!


