**Hexagonal architecture** is a technique which involves splitting out modules that are used by a [[AWS Lambda|Lambda]] function so that each one can be easily swapped out by a different implementation. ## Arguments for: The reasons why you might want to swap out the implementation are: - To swap in a [[Test double]] - For flexibility of using a different concrete implementation in the future. Helps avoid [[Vendor Lock-in]]. ## Arguments against: - Extra code to write - Adds multiple layers of indirection to your code which makes it harder to read - The interface to your "wrapper" needs to maintain consistency with the underlying concrete service. If the goal is to have a general purpose API, then this interface design becomes more difficult as you need to take into account all potential implementations and may end up with lowest common denominator implementation --- ## References - [Big Bad Vendor Lock-in](https://vacationtracker.io/blog/big-bad-serverless-vendor-lock-in) by [Slobodan Stojanović](https://vacationtracker.io/author/slobodan). See section on "Designing testable serverless apps using hexagonal architecture" - [Hexagonal Architecture: A High Level Overview](https://dev.to/harrisgeo88/hexagonal-architecture-a-high-level-overview-174g)