Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Any way to store bearer token in AWS Lambda function?

Lambda function is idempotent.

I'm calling one of the REST api which has ClientId and Client Secret.

Now, for each request I have get bearer token and send response.

I know, I can store bearer token in Cloud Database(DynamoDB), but is there any alternative?

like image 534
Jagdish Idhate Avatar asked Apr 06 '17 07:04

Jagdish Idhate


1 Answers

As far as I know, the lambdas are actually run in containers that are launched and killed on the background without you doing anything. That's why the first call to your function (or a call after there were no previous calls for some time) may take longer... because new container with your environment needs to be initialized. So between two lambda calls, the whole environment in which it was running might have been torn down and respawned again...

In other words, there is nothing in the lambda runtime environment that you can count on to find there on the next call, except your source, attached libraries and the configuration that you set up when you created it.

What's wrong with saving the tokens in DynamoDB or AWS hosted REDIS? It's gonna be like 3-4 lines of code and if you use Dynamo, it's probably not gonna be very expensive either.

like image 139
grepe Avatar answered Sep 18 '22 16:09

grepe