This section we will walk you through all the steps needed to deploy the lambda layer needed for the lambda function to include AI21 Lab's Python SDK library. This SDK is needed for the lambda function to communicate with the Jurassic-2 model.
The purpose of the lambda layer is to give your lambda function access to libraries and custom runtimes that are not part of the of the AWS Lambda service natively. If you are not familiar with what lambda layers are you can learn more here.
This section will cover packaging up your lambda layer to upload to the AWS Lambda service.
- This repo includes the requirements.txt file in the following directory ./lambda_layer > requirements.txt file with the names of the libraries that will be packaged with your lambda layer.
- Navigate to the ./lambda_layer directory from your terminal.
- Next run the command below.
If you don't have pip3 installed you can find instructions here here
pip3 install -r requirements.txt -t ./python/lib/python3.9/site-packages && zip -r lambda_layer.zip ./python && rm -R ./python
-
If you have followed all the steps correctly you should have a folder containing the zipped lambda layer similar to the image below.
Note: The lambda_layer.zip contains our lambda layer.
-
To deploy the layer in your AWS account you will login and navigate to the AWS Lambda service.
-
Next you will navigate to the Layers section in the menu on the left. See image below.
-
You will then click the Create layer button in the upper right-hand corner. See image below.
-
On the next screen you will fill in the layer configuration info. See example below.
For the Upload section you will navigate to the python.zip folder you created in the previous section.
-
Once you have fill out the needed info you will click the Create button, and should see a screen similar to the one below.
You have now successfully created the lambda layer that will be used by the lambda function that you will deploy in the next section.
Previous < Deployment Guide | Next > Deploying CloudFormation template