Jagdish Idhate
Jagdish Idhate

Reputation: 7742

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?

Upvotes: 8

Views: 2888

Answers (1)

grepe
grepe

Reputation: 1977

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.

Upvotes: 4

Related Questions