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/";
?