1

I am trying to invoke a lambda function locally that invokes another lambda function, also local.

I am using sam local start-lambda -t notificationServiceTemplate.yml --docker-network lambda-local --host 0.0.0.0

I then start my consumer lambda, that invokes the worker lambda,

aws lambda invoke --function-name ImportUsageConsumerLambda --endpoint-url http://127.0.0.1:3001

The consumer lambda function makes the invoke call using these parameters,

if (process.env.STACK_ENVIRONMENT == "local" ) {
     options.endpoint = "http://0.0.0.0:3001/";
     options.sslEnabled = false;
 }
 lambda = new AWS.Lambda(options);

It doesn't work because the lambda container cannot access localhost in outside the container, UnknownEndpoint: Inaccessible host: '0.0.0.0\'. This service may not be available in the 'us-west-2\' region.\n.

I understand using the endpoint 0.0.0.0:3001 will not work because that is where the start-lambda setups the lambda endpoint that is accessible to my host and not the same network as within the lambda docker container.

I've managed to get connected to a dynamodb docker container following this question and answer here.

Is there a simple way to do this that I am missing? Like a hostname of the lambda container that I can call from inside the lambda container, i.e. options.endpoint = "http://lambda:3001/";?

natemacinnes
  • 304
  • 4
  • 10
  • localhost is not 0.0.0.0, it's 127.0.0.1. It's not clear why you are using 127.0.0.1 as the endpoint in one place but not the other. – Michael - sqlbot Nov 11 '18 at 01:37
  • Thanks, that is true. I was using 127.0.0.1 in all places, but in my vain attempts to connect the two I tried using host 0.0.0.0 – natemacinnes Nov 11 '18 at 01:43

1 Answers1

-1

I have had some success using host.docker.internal:PORT for connecting my local lambda to my container running django.

RESlyder
  • 11
  • 1
  • 2