Differences between SecretCache and Lambda Extension

0

In case of Java Lambdas, is there any practical benefit in using SecretCache (https://docs.aws.amazon.com/secretsmanager/latest/userguide/retrieving-secrets_cache-java.html) over Secrets Lambda extension via layer (https://docs.aws.amazon.com/secretsmanager/latest/userguide/retrieving-secrets_lambda.html) and viceversa?

I could not find any comparison documentation, thanks.

profile picture
EXPERT
asked 9 months ago284 views
1 Answer
1
Accepted Answer

Hi, I may be wrong (I didn't test in details) but I see at least one interesting difference:

  1. the Secret cache is local to your Lambda execution. So, it's useful if you make several calls to SecretManager to obtain same secret multiple time during the execution of your Lambda.
  2. The Lambda extensions can be shared across multiple executions: so, you get the benefits of caching (less cost due to less API calls, reduced latency) multiple times.

This article shows the results across multiple executions with AWS Lambda Extension for Secrets: https://www.element7.io/2022/12/boost-performance-and-reduce-costs-using-lambda-extensions/

On https://github.com/aws/aws-secretsmanager-caching-java, the recommendation is to use the Secret Cache with

private final SecretCache cache = new SecretCache();

In this form, it will go away at the end of each Lambda execution

Best, Didier

profile pictureAWS
EXPERT
answered 9 months ago
profile picture
EXPERT
reviewed a month ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions