Hi everyone, it is my very first post so excuse me...
# help
j
Hi everyone, it is my very first post so excuse me if I missed something. I’m interested in calling lambda from another lambda, the 1st one is Node-based and deals with the upload itself + some validation but I would like to invoke another one which is processing the data using Python, I have found this PR about attaching permissions but I got stuck how to proceed further. Thank you
t
If you have your two functions
Copy code
const f1 = new sst.Function(...)
const f2 = new sst.Function(...)
You can do
f1.attachPermissions(f2)
j
Thanks, I have found the PR about attaching permission but I don’t know how to invoke one function from another one. I saw examples using
aws-sdk
but I guess that’s not the correct way as I would lose live development
t
You can do it just as you would normally, live development will still work 😄
j
The thing is, I have absolutely no idea how to do it normally 🙂
t
Copy code
const lambda = new Lambda()
lambda.invoke(...)
I don't remember the exact args but you should be bale to look that up
That said, one lambda invoking another lambda is usually an anti-pattern. Can you tell me more about your setup?
j
Thank you. Sure, I would like to have a Node-based lambda which processes the uploaded file and in some cases invokes another lambda (this one is python-based as I found working with pdfs easier in python) to extract some data from the PDF. This extractData lambda will be later used by multiple parent lambdas
t
Ah got it you're going across languages. That makes sense
Look into step functions if you haven't already, they're a better way to coordinate workflows that involve multiple lambdas. Can be overkill though if your setup is simple
j
I saw a few mentions about them when searching for a solution but thought it’s not related, will check them 👍