Best practices for working with AWS Lambda functions
The following are the recommended best practices for using AWS Lambda:
Function code
The following are the best practices for function code:
- You can separate your entry point or Lambda handler logic into core logic to create more unit-testable functions.
- You can improve the performance of your function code by taking advantage of externalized configurations or dependencies for the code, so that you can retrieve the referenced code and store it locally after its initial execution. You can limit the re-initialization of objects and/or variables on every invocation. Reuse the existing connections and keep the previous connections alive, which were established during previous invocations.
- To pass operational parameters, you can use environment variables for your functions. Let's say you want to use the Amazon S3 bucket name in your function. You can pass this value as an environment variable instead of hard-coding the bucket name.
- You can control...