red888
red888

Reputation: 31652

How does AWS know where my imports are?

I'm new to AWS Lambda and pretty new to Python.

I wanted to write a python lambda that uses the AWS API.

boto is the most popular python module to do this so I wanted to include it.

Looking at examples online I put import boto3 at the top of my Lambda and it just worked- I was able to use boto in my Lambda.

How does AWS know about boto? It's a community module. Are there a list of supported modules for Lambdas? Does AWS cache its own copy of community modules?

Upvotes: 1

Views: 83

Answers (3)

Aurora0001
Aurora0001

Reputation: 13557

The documentation seems to suggest boto3 is provided by default on AWS Lambda:

AWS Lambda includes the AWS SDK for Python (Boto 3), so you don't need to include it in your deployment package. However, if you want to use a version of Boto3 other than the one included by default, you can include it in your deployment package.

As far as I know, you will need to manually install any other dependencies in your deployment package, as shown in the linked documentation, using:

pip install foobar -t <project path>

Upvotes: 3

Chenna V
Chenna V

Reputation: 10513

AWS Lambda includes the AWS SDK for Python (Boto 3), so you don't need to include it in your deployment package.

This link will give you a little more in-depth info on Lambda environment https://aws.amazon.com/blogs/compute/container-reuse-in-lambda/

And this too https://alestic.com/2014/12/aws-lambda-persistence/

Upvotes: 1

kichik
kichik

Reputation: 34744

AWS Lambda's Python environment comes pre-installed with boto3. Any other libraries you want need to be part of the zip you upload. You can install them locally with pip install whatever -t mysrcfolder.

Upvotes: 3

Related Questions