I have a AWS Lambda function that creates an object from a s3 call in cold start. I then hold the object in the cache while the function is warm to keep load times down. When files are changed in s3, I have a trigger to run the lambda, but not all the running instances of lambda restart and pull from s3.
Is there a way to bring down all instances of lambda forcing a full cold start?
Also, I don't want to use python.
To restart the instance, Lambda will require an execution role with allowed permissions. Following permissions code will allow the Lambda function to log permissions into cloudwatch logs, and allows permissions to start and stop EC2 instances.
Cache data is stored in memory and not in a file within the Lambda execution environment. This means that no additional process is required to manage the lifecycle of the file. In-memory is also more secure, as data is not persisted to disk for subsequent function invocations.
I made an Answer based on my comment and verification from @DejanVasic
aws lambda update-function-configuration --function-name "myLambda" --description "foo"
This will force the next invokation of the lambda to "cold start".
To verify:
@timestamp, @message | sort @timestamp desc | limit 1000 | filter @message like "cold_start:true"
Use the UpdateFunctionCode
API endpoint to force a refresh of all containers. AWS SDKs wrap this up to make it easier for you to call the API using your preferred language.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With