We can create a deployment package that includes the dependencies and the source code for the function.
Here are steps to create the deployment package:
Create a virtual environment for the project:python3 -m venv myenv-coding
source myenv-coding/bin/activate
Note: for custom the specific python version, we can use command python3.8 -m ... or use soft link /usr/local/bin/python3 to the Python Path
Install the dependencies in the virtual environment:Example we need below dependencies:
Package the virtual environment and the source code into a deployment package:pip install boto3
pip install argparse
pip install gspread
cd myenv-coding/lib/python3.8/site-packages/
zip -r9 ${OLDPWD}/function.zip .
cd $OLDPWD
zip -g function.zip <source_code>.py
Upload the deployment package to AWS Lambda using the AWS Management Console, AWS CLI, or the AWS SDK.We can then test the function in the AWS Lambda Console to verify that it works as expected.
Thank You.
Comments
Post a Comment