4.Here, you can use AWS cli to create functions, or you can upload the zip package directly through AWS console (an example is as follows)
A.AWS Console upload
B.AWS cli creates the function and specifies the zip package
Please modify the corresponding parameters by yourself, such as ARN of Iam
bash-4.2# aws lambda create-function --function-name my-func --zip-file fileb://my-function.zip --handler lambda_function.lambda_handler --runtime python3.6 --role arn:aws:iam::your-account-id:role/lambda-ex
2.There are third-party dependent packages
Set the directory structure of the deployment package (. Zip file).
Create a deployment package for lambda functions with runtime dependencies.
Use AWS cli to upload deployment package and create lambda function.
Call lambda function to return source code
Create lambda as a deployment package Zip file.
1. Create the function (mylib func) project directory and enter it
bash-4.2# mkdir mylib-func
bash-4.2# cd mylib-func
3.Install the request Library in the new package directory.
bash-4.2# pip3 install--target ./package requests
4.Use the installed library to create the deployment package in the root directory (create a zip package in the parent directory and add the things in the package directory to the zip package)
bash-4.2# cd package/
bash-4.2# zip -r ../mylib-func.zip .
5.Lambda_function. Add the PY file to the root directory of the zip file
bash-4.2# zip -g mylib-func.zip lambda_function.py
adding: lambda_function.py (deflated 32%)
bash-4.2#
6.Upload package to AWS lambda
A. AWS cli creates a function and selects a package (please modify the corresponding parameters by yourself)
Top comments (0)