Using a Lambda layer

Let's have a go at creating our own Lambda layer using the console and then see if we can share it with another account. For this example, we're going to create a layer in Python that simply passes a message back to our handler. Let's get started:

  1. We'll start by writing the code that will make up our layer. The following is a super simple function that returns a message:
def provide_message():    return "Hello Lambda learners!"
  1. Save that file as message_vendor.py, in a folder called python. This is important because our layer gets extracted into the /opt directory. The directory is automatically added to the path variable, making it easily accessible to our actual function. We must make sure we are following the directory ...

Get Learn AWS Serverless Computing 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.