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 ...

Get Expert AWS Development now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.