Support Documents
No data found.

Install Python modules in AWS Lambda using Cloud9

Lab Details

  1. This lab walks you through the steps to install external libraries to your Lambda function using Cloud9 Environment if your code has additional dependencies on libraries other than the AWS SDK and include them in your deployment package (.zip file).

  2. You will practice using AWS Cloud9 and Amazon Lambda.

  3. Duration: 45 minutes

  4. AWS Region: US East (N. Virginia) us-east-1


What is AWS Cloud9 ?

  1. AWS Cloud9 is an integrated development environment, or IDE.

  2. The AWS Cloud9 IDE offers a rich code-editing experience with support for several programming languages and runtime debuggers. It also has a built-in terminal with a preconfigured CLI.

  3. It contains a collection of tools that you use to code, build, run, test, and debug software.

How does AWS Cloud9 Work?

  1. We use the AWS Cloud9 IDE, running in a web browser on your local computer, to interact with your AWS Cloud9 environment.

  2. A computing resource like an EC2 Instance or our own server connects to that environment.

  3. Your work is stored in an AWS CodeCommit repository or another type of remote repository.

Amazon Lambda

  • AWS Lambda is a Serverless Compute service.

  • It works without any servers and allows us to execute code for any type of application.

  • The developer doesn't have to worry about the AWS resources to launch or the steps needed to manage the resources.

  • The configuration of the tasks are done as code . They are implemented in Lambda and performed on execution.

  • Provisioning and Managing are both taken care of by the Lambda function.

  • The languages AWS Lambda supports are Node.js, Python, C#, Java and Go.

  • It allows us to run code in response to events from other AWS services.

  • Automatic Scaling is done based on the size of the workload.

  • The Lambda Code is executed from Triggers which are received from AWS resources.

  • The cost of AWS Lambda is very low and depends on multiple factors. It will charge for every 100ms of runtime also for the number of times the code is executed.

  • The allowable runtimes a Lambda function execution is between 100ms to 15 Mins.

  • It offers resources varying from 128MB of memory to 10GB of memory.

Case Study

  • While working with lambda we need to use lots of packages in our code and some of these packages are not available in the lambda function. These are called additional dependencies.

  • Requests module is one of the most downloaded Python packages today, pulling in around 14M downloads/week according to GitHub, Requests is currently depended upon by 500,000+ repositories.

  • We will be adding the Requests module to lambda function using Cloud9 because of its user friendly IDE which makes it easy.

  • You can also perform this lab in your local machine terminal or using the AWS Powershell and upload the deployment package to Lambda function.

Architecture Diagram

Task Details

  1. Launching Lab Environment.

  2. Create a Lambda function.

  3. Create an AWS Cloud9 development environment.

  4. Import the Lambda function to Cloud9

  5. Install requests Library and download it.

  6. Upload the deployment package and test.

  7. Validation of the lab.

  8. Deleting AWS resources


AWS recommended to use Google Chrome Browser for Cloud9 IDE.

Click the link to download Google Chrome :