how to invoke a local lambda function from sam local api #4800
Unanswered
Powerleech
asked this question in
Questions
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I am running a api with aws-sam that points to a flask based lambda function which is my app.
Here is the template.json for sam:
I then have another lambda function, that I wish to invoke from my flask application.
I start my api with
sam local start-api --docker-network sam-network
.in my app.py I have:
I started my other lambda function locally with
sam local start-lambda --docker-network sam-network
Now I have the api on
http://127.0.0.1:3000
, and I have my local lambda functions running on http://127.0.0.1:3001.
If I try to invoke the local lambda function from command line with a curl on port 3001, it works fine.
When I curl my api:
curl http://localhost:3000/hello
the flask application executes the
/hello
as expectedBut my flask application cannot invoke my EmailSender function runnning locally in SAM:
error message
Am I doing something wrong?
I realize that the problem might be the "localhost" part in the flask application, but I haven't been able to figure out what to put instead. If I use --docker-network, and tries the docker's internal ip, it wouldn't work.
Could anyone point me in the right direction?
Beta Was this translation helpful? Give feedback.
All reactions