2 Answers
- Newest
- Most votes
- Most comments
0
Hello, I was thinking that you might just capture that config data into a JSON file in your /tmp directory - like /tmp/config.json
Then your Lambda function would first check for the existence of that file before it queries the database. Would that work for your use case? As long as the Lambda is being warm started, I believe the /tmp folder will remain intact on the next invocation.
answered 2 years ago
0
Hi,
I see a few options, of course depending on your case.
- If your data is pretty much static and not sensitive, you can opt for lambda environment variables instead of DB
- Use Lambda extensions: https://aws.amazon.com/blogs/compute/caching-data-and-configuration-settings-with-aws-lambda-extensions/. The article references that one of the types of cache to consider in this situation is data cache for caching data from databases such as Amazon Relational Database Service (Amazon RDS), or DynamoDB, so the approach will work/apply also for RDS. You will need to write your own RDS plugin as was done for Dynamo (https://github.com/aws-samples/aws-lambda-extensions/blob/main/cache-extension-demo/plugins/dynamodb.go) and of course change the SAM templates so that it creates/reference an RDS database.
- Asimpler alternative is to use extension to load configuration from SSM Parameter store instead: https://aws.amazon.com/blogs/compute/using-the-aws-parameter-and-secrets-lambda-extension-to-cache-parameters-and-secrets/. I wrote an example of that in this article: https://medium.com/aws-in-plain-english/potential-costs-and-latency-improvements-with-aws-parameters-and-secrets-lambda-extensions-40b6af151b0.
- Of course other options are Redis/ElasticCache, but you excluded that in your enquire, so not going into details for that.
Hope it helps!
Relevant content
- asked a year ago
- AWS OFFICIALUpdated 3 years ago
- AWS OFFICIALUpdated 6 months ago
- AWS OFFICIALUpdated a year ago
- AWS OFFICIALUpdated 3 years ago
Hello @patrick but data in config file can change so I want to use new changed data without any deployment effort.