0

I am trying to run a lambda function written in Go using AWS sam local invoke, but cannot connect to the dynamodb running in the cloud.

I've tried tunneling and portforwarding to the database in Putty. Specifying the host and port to my own ip and port.

The command I use to run the lambda: sam local invoke -t ./qa.yaml -e ./s3_event.json

I expect that it should run the lambda, but it gives this connection error:

tcp 192.168.x.xxx:5433: connect: connection refused","data":{"database":"analytics"}}

  • Your question is not clear to me: Is the problem running the lambda from a remote machine or connecting from the lambda to your DB. – Nir Alfasi May 15 '19 at 18:34
  • It is connecting from the lambda (locally, which is run with sam local invoke) to the db. – user3647101 May 15 '19 at 18:35
  • Instead of a local db, like this post: https://stackoverflow.com/questions/48926260/connecting-aws-sam-local-with-dynamodb-in-docker. I am trying to connect to a dynamodb hosted on aws. – user3647101 May 15 '19 at 18:37

1 Answers1

1

The problem was using 127.0.0.1 as my host. I had to switch it to host.docker.internal.

source: https://docs.docker.com/docker-for-mac/networking/#i-want-to-connect-from-a-container-to-a-service-on-the-host