1

This question is related to serverless-offline plugin, local mysql database connection. The scenarios for my test is as follows.

  1. Using serverless-offline plugin, a lambda function is deployed locally on my machine.
  2. The triggered lambda is not possible to connect with the local database.

Probably, serverless-offline creates a docker image to launch a lambda, and the address is not correct in the docker container and port mapping. However, serverless-offline does not support those docker options. I am stuck here to connect the database from the lambdas deployed locally with serverless-offline.

I used localhost:3306 for the db host, but it does not work. I tried port forwarding to connect the database via public ip address which does not work.

The database connection can be established somehow, but the connection is refused all the time. Any help?

  • As far as I know, servereless-offline does not use docker, can you share a bit more you're configuration? What's the error you're getting? – dege Nov 02 '19 at 10:27
  • @dege Thanks for your reply. A lambda function written in golang will be launced on a docker contaniner AFAIK. – user12304186 Nov 03 '19 at 15:20

1 Answers1

0

I'll do my best to address several areas of your post in order of their appearance

serverless-offline creates a docker image to launch a lambda

Incorrect. Serverless Framework and its plugins (serverless-offline, etc.) have absolutely nothing to do with Docker, or Docker related technologies.

I used localhost:3306 for the db host, but it does not work

From your post, I am gathering that you simply do not have a MySQL service running on your local machine. Is that what you need? Reply to this post and I'll try to help, or simply google examples of how to install/start/configure a MySQL server.

I tried port forwarding to connect the database via public ip address which does not work.

I assume you're talking about the popular ssh -L trick to connect to a remote database over SSH connection? From your post, I am gathering that you simply are not performing this operation correctly. Do you need help doing that? Reply to this post and I'll try to help, or simply google examples of how to use SSH Port Forwarding to connect to a MySQL database.

Sean Linguine
  • 364
  • 1
  • 7