Help us improve the AWS re:Post Knowledge Center by sharing your feedback in a brief survey. Your input can influence how we create and update our content to better support your AWS journey.
How do I deploy Lambda functions with external libraries using AWS Cloud9?
2 minute read
0
I want to add external libraries to an AWS Lambda function that I developed using AWS Cloud9. How do I do that?
3. In the left navigation pane, choose Environment. The Environment window opens.
4. Open the context (right-click) menu for your function's parent folder. Note: Your function's parent folder is listed with the same name as your function.
6. Import an external library module by running the following pip command in the new terminal:
Important: Replace ModuleName with the name of the module that you want to import.
python -m pip install --target=./ ModuleName
Note: To make sure that the correct versions of Python packages are installed, it's a best practice to specify a requirements.txt file in the pip command. For more information, see the Requirements file format section of the pip documentation.
7. Repeat step six for each module that you want to import. The imported modules appear in your function's parent folder.
Deploy your Lambda function using the AWS Toolkit
Follow the instructions in Deploying a serverless application in the AWS Cloud9 User Guide. After deploying your function, you can run your code using the additional modules that you imported.