As discussed earlier, in the previous article, Lambda Functions can be written to perform complex operations as well which might require multiple libraries or modules. For example — Extracting face from images using MXNET, downloading images using links. For these use cases, we will need multiple libraries packed in the execution environment, as coding it from the scratch will be very complex. So, to deploy those we will have to provide the required libraries to the lambda instances since, lambda instances only have specific libraries to work with.

One more thing to notice is AWS Lambda Instances are actually Amazon Linux based instances, which are different from Ubuntu environments and might have different codes for different modules. Due to this reason, a lot of people have faced import issue of PIL library with python while using it in Lambda Functions.

To overcome this issue, I would suggest using docker to build runtime environments for scripts and installing libraries and testing it on the same environment. I would brief you about the usage of docker in downloading modules for Amazon Linux instances. Post that, we will see how to form Custom Layers and configure layers for AWS Lambda Functions along with creating a lambda function triggered using Object Creation on S3 Bucket and downloading images using data in the files.

Starting off with using docker to download modules for Amazon Linux Instances. Docker facilitates containerization or operating-system-level virtualization. We first need to install docker.

#docker #aws #python #serverless #aws-lambda

Going Serverless with AWS Lambda Functions 
1.20 GEEK