The solution that's documented in this tutorial uses several libraries that aren't included with the standard Python package that Lambda uses. To use these libraries, you first have to download them on your computer. Next, you create a .zip archive that contains all of the libraries. Finally, you upload this archive in Lambda so that you can call the libraries from your functions.
Note
This procedure assumes that you've already installed Python. Python is included by default with most recent Linux, macOS, or Unix distributions. If you use Windows, you can download Python from the Python Releases for Windows page on the Python website. This solution was tested using Python version 3.7.3 on macOS High Sierra, Ubuntu 18.04 LTS, and Windows Server 2019.
To download the libraries that are required for this tutorial
-
At the command line, enter the following command to install the
virtualenvpackage:python -m pip install virtualenv -
Enter the following command to create a new directory for the virtual environment:
mkdir ~/pinpoint-importer
new-item pinpoint-import -itemtype directory
-
Enter the following command to change to the
pinpoint-importerdirectory:cd pinpoint-importer -
Enter the following command to create and initialize a virtual environment called
venv:python -m virtualenv venv -
Enter the following command to activate the virtual environment:
source venv/bin/activate
.\venv\Scripts\activate
Your command prompt changes to show that the virtual environment is active.
-
Enter the following command to install the packages that are required for this tutorial:
pip install s3fs jmespath s3transfer six python-dateutil docutils -
Enter the following command to deactivate the virtual environment:
deactivate -
Enter the following command to create an archive that contains the necessary libraries:
cd venv/lib/python3.7/site-packages && \
zip -r ~/pinpoint-importer/pinpoint-importer.zip dateutil docutils jmespath \
s3fs s3transfer six.py && cd -
In the preceding command, replace 3.7 with the version of Python that's installed on your computer.
cd .\venv\Lib\site-packages\
Compress-Archive -Path dateutil, docutils, jmespath, s3fs, s3transfer, six.py `
-DestinationPath ..\..\..\pinpoint-importer.zip ; cd ..\..\..