Search code examples
amazon-web-servicesaws-lambdaaws-secrets-manager

Is AWS lambda function doing some caching when it retrieves an AWS secret


I noticed that when i updated the secret, it takes sometime before the lambda is able to retrieve the updated secret value. I wonder if there is some caching happening during lambda invocation.


Solution

  • The only builtin caching I'm aware of in lambda function is the execution context reuse, which is documented here.

    Take advantage of execution context reuse to improve the performance of your function. Initialize SDK clients and database connections outside of the function handler, and cache static assets locally in the /tmp directory. Subsequent invocations processed by the same instance of your function can reuse these resources. This saves execution time and cost.

    To answer your question, if you fetch the secrets outside the function handler, then it will take some time to fully update in the execution context.