...
/Multiple Lambda Functions - Configuring Providers and Plugins
Multiple Lambda Functions - Configuring Providers and Plugins
Learn to package and share code libraries across Lambda functions using Layers.
Introduction
Having gained some basic knowledge of the main components of Serverless and how to deploy our service, let’s gradually build on that knowledge by looking at more advanced configurations and examples.
In this example, we will deploy a service that consists of the following:
-
Two AWS Lambda functions: There is a particular way to organize the folder structure and each function’s dependencies when deploying multiple functions together in one service.
-
Lambda layers: Lambda layers are useful if we have dependencies that are too large in a function or if we have the same dependencies shared among many functions. This saves us deployment time and improves managing and sharing common dependencies.
-
Separate configuration files per environment (
config.dev.yml
andconfig.prod.yml
): These are very useful when we have different configurations per environment—for example, memory allocation. We currently have two ways we can achieve environment configuration in SLS.
Main serverless.yml
components
We'll cover every component of the serverless.yml
file in detail to give a full picture of what to pay attention to when creating our own service configuration. Please also note comments and recommendations written directly in the code. The main components we'll use in most of our services are:
### Section where we define most general settings of our applicationorg: ORGapp: serverless-101service: sls-aws-python-starter-extendedframeworkVersion: '3' # We would recommend to go directly for the latest major release, if we're not in need of migratingprovider:### Section where we define plugins used by our applicationplugins:custom:### Section where we define different parameters per stageparams:### Section where we define what files to packagepackage:### Section where we define lambda layerslayers:### Section where we define your functionsfunctions:
-
org
,app
,service
andframeworkVersion
: ...