1

I'm working on GitHub authorization and have to compare two strings (Github state and local state). A separate module (file) is used to store and retrieve states. In the first function, I put the value in an object defined in that module, in the second function I try to extract this value. The functions were running on localhost successfully, but once the app is deployed I'm not able to retrieve the string. It seems like it's initializing a new instance of that module for each function. Maybe there are other ways for transferring data between the functions (short term storage, can be stored in RAM)?

Felipe Sulser
  • 1,185
  • 8
  • 19
iamskok
  • 600
  • 5
  • 19
  • Please see if this link helps: [Passing Parameters between 2 AWS Lambda Functions](https://stackoverflow.com/questions/50342504/can-i-pass-path-parameters-using-lambda-invoke-to-another-lambda-function) – TechFree Jun 05 '19 at 07:23
  • When you refer to "functions", are you meaning AWS Lambda functions? Are these two different functions, or two invocations of the same function? AWS Lambda functions are containerized. There is no communication between separate Lambda functions (and no guarantee of communication between separate invocations of the same function). – John Rotenstein Jun 06 '19 at 04:33
  • Yep, I mean AWS Lambda functions (to be specific I'm using them on [Netlify](https://www.netlify.com/docs/functions/)). Those are two different functions [`auth` and `access-token`](https://github.com/iamskok/gatsby-dev-blog-starter/tree/master/.netlify/functions). – iamskok Jun 07 '19 at 07:41

1 Answers1

2

Your two Lambda functions run in separate, isolated containers and have no access to each other's local state. For sharing state between functions we have a number of options:

  • Use an external storage such as DynamoDB
  • Store state in client, for example a browser/mobile app
  • Chain functions: after computing your state in function A, invoke function B, passing computed state as an input parameter
Aleksi
  • 4,483
  • 33
  • 45