IT Infrastructure Manager

How to add Lambda-Layers


(This guide is based on Python 3.9 version and Windows PC)


※ Before we begin, please check your python version in your local PC. you can check your python version by this command

PS C:\Users> pip --version
pip 22.0.4 from C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.3568.0_x64__qbz5n2kfra8p0\lib\site-packages\pip (python 3.9)


1. First, you need to make proper directory to download external library.
The location should be like this format

 /your_package_name/python/

2. After you make directory, move to that directory by shell program

cd /your_package_name/python/


3. And now you are ready to download the external library in your local computer

 pip install [Package name] -t [your_package_name/python/] --no-user


4. Once you install the package, your package directory should be look like this

lambda_1

5. Move out to [your_package_name/path]

  cd ../..


6. And then, you should zip the directory as its package name.
(In this example, I used PowerShell script. But if you have another Zip-File maker (ex. Winzip), you can use it )

 ##This line works only in PowerShell! 

  Compress-Archive -Path ./[your_package_name] ./[your_package_name].zip


7. Now you finished to created package file to upload! Move on to AWS Lambda Console

lambda_2


8. Go to [Additional Layers] - [Layers] and then press [Create Layer] Button on Console

lambda_3


9. Fill out the Name and Description then select [Upload a .zip file] among radio button. After that press [Upload] button.

lambda_4

You can also add compartible runtimes and license as options


※ Pacakge file must be below 10MB. If its not, you should upload by S3


10. And now you succesfully uploaded python package into Lambda layer

lambda_5


11. You can add your custom layer when you editing Lambda function like this


lambda_6


lambda_7


lambda_8

- If you can’t find your layer when you about to add, return to Lambda Layer page and add proper [Compartible architectures] and [Comaprtible runtimes].

lambda_9