'How to share data among many AWS Lambda functions?

I have 8 different AWS Lambda functions that need to share some common data. (like common configuration for database, etc)



Solution 1:[1]

There is no in-built technique for sharing data between Lambda functions. Each function runs independently and there is no shared datastore.

You will need to use an external datastore -- that is, something outside of Lambda that can persist the data.

Some options include:

  • Amazon S3: You could store information in an S3 object, that is retrieved by your Lambda functions.
  • Amazon DynamoDB: A fully-managed NoSQL database that provides fast performance. Ideal if you are storing and retrieving a blog of data, such as a JSON object. Your Lambda function would access DynamoDB via standard API calls. For extreme performance, you could use DynamoDB Accelerator (DAX).
  • AWS Systems Manager Parameter Store: Provides secure, hierarchical storage for configuration data management and secrets management.

The above options are fully-managed services, so you don't need to run any extra infrastructure.

There are other options, such as Amazon ElastiCache, but they would require additional services to be running.

Solution 2:[2]

Depending on the nature of configuration you can decide on using different storage options.

If the configuration doesn't change often and mostly static you can use the following options,

  • Amazon Systems Manager Parameters Store
  • Embed configuration as a part of code

If they are changing often you can consider,

  • AWS DynamoDB
  • AWS S3

Note: Depending on your use case you can also consider these configurations as parameters to these Lambda functions.

Solution 3:[3]

I will add my 2 cents answer :

  • use lambda-layer (50mb) for persistent share data over function invocation
  • use EFS (ec2, within vpc) for persistente share data over any aws service

the lambda temporary memory (default 512mo extand recently to 10 gb) in ephemere only for current evocation.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 John Rotenstein
Solution 2 Ashan
Solution 3 mis7er.n9o