Structuring a function

In Chapter 3, The Foundations of a Function in AWS, we learned about the handler of a function and how that was the special entry point that handles the processing of events. We also built our own functions that had logic and did things within the handler function itself. It turns out that's not the optimal way to structure a Lambda function, and here's why.

It's better to approach Lambda development by splitting a function into three main areas of responsibility. These areas are as follows:

  • Handler
  • Controller
  • Service abstraction

Each area forms a physical separation of code and allows you to be smarter about how the code is used. The following is a representation of how each area is logically implemented:

Logical implementation of a Lambda function

In the following subsections, we'll explain these areas in depth.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.14.252.56