I have written a lambda function which does some processing.
There is 1 environment variable which is set by default.
Is there a way I can change it after every run ?
I have written a lambda function which does some processing.
There is 1 environment variable which is set by default.
Is there a way I can change it after every run ?
If you are not happy with DB, as suggested in comment then you can use AWS store parameter which will answer your this query.
way to modify environment variable in AWS Lambda?
You can consume Your environment variable from the store parameter, also it will keep the state across different lambda function, Variable outside handle may work as suggested @Jan, but what if you update the lambda function?
So, for example, the flow will be
If store-paramter == true;
#do the job,after job done
#update store-paramter value
store-paramter=false
else
#play with with value
once you generate secret in secretsmanager , AWS will popup with complete code in a different language just copy the code and paste it in lambda that sample but you should assign permission to lambda.
Also, you explore a handy npm package aws-param-store.
BTW application should not update ENV, but to deal with your use case you can follow.
You can check this article too from scratch how to set and consume secret in lambda.
Environment variables are made to pass settings to your Lambda. They aren't the right tool for keeping your state.
DynamoDB is a serverless database made exactly for that purpose. It is easy to create a table that will store just one value.
Within free tier you can get 25GBs and opportunity to make up to 25 write/read requests a second.