Invoke Lambda Locally from Local Lambda











up vote
0
down vote

favorite












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










share|improve this question






















  • 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 at 1: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 at 1:43















up vote
0
down vote

favorite












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










share|improve this question






















  • 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 at 1: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 at 1:43













up vote
0
down vote

favorite









up vote
0
down vote

favorite











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










share|improve this question













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







docker aws-lambda docker-compose docker-networking aws-sam-local






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 10 at 22:25









natemacinnes

3526




3526












  • 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 at 1: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 at 1:43


















  • 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 at 1: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 at 1:43
















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 at 1:37






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 at 1: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 at 1:43




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 at 1:43

















active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














 

draft saved


draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53244027%2finvoke-lambda-locally-from-local-lambda%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown






























active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes
















 

draft saved


draft discarded



















































 


draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53244027%2finvoke-lambda-locally-from-local-lambda%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Florida Star v. B. J. F.

Danny Elfman

Retrieve a Users Dashboard in Tumblr with R and TumblR. Oauth Issues