简体   繁体   中英

Serverless Framework - AWS Lambda dependency limit exceed

I am working in a serverless project with AWS (a kind of call center, using Twilio). I have previously built another 2-3 little projects. I am using Serverless Framework now, though. I didn't use it so far. So I am quite a newbie in both, AWS and Serverless.

I am somehow following the next link: https://serverless.com/blog/flask-python-rest-api-serverless-lambda-dynamodb/

So I am basically using this Python dependecies: Flask, Twilio, boto3 (for AWS). See requirements.txt below. I uninstalled some packages, however there probably are some packages I could clean:

boto3==1.9.84
botocore==1.12.84
certifi==2018.11.29
chardet==3.0.4
Click==7.0
docutils==0.14
Flask==1.0.2
idna==2.8
itsdangerous==1.1.0
Jinja2==2.10
jmespath==0.9.3
lazy-object-proxy==1.3.1
MarkupSafe==1.1.0
pipdeptree==0.13.2
PyJWT==1.7.1
PySocks==1.6.8
python-dateutil==2.7.5
pytz==2018.9
requests==2.21.0
s3transfer==0.1.13
six==1.12.0
twilio==6.23.1
urllib3==1.24.1

Using Serverless Framework I was able to deploy (serverless deploy) the project without issues until I installed boto3. However, now I exceed allowed dependency size and get this error:

An error occurred: AppLambdaFunction - Unzipped size must be smaller than 262144000 bytes (Service: AWSLambdaInternal; Status Code: 400; Error Code: InvalidParameterValueException; Request ID: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx).

I'm stuck on this. I guess I could solve it the old way, without using Serverless Framework (directly in AWS), but I would ideally like to solve this issue.

Is it possible to partially install boto3? I mean, a way to install just the modules I need.

Any other idea?

Thanks in advance.

Luckily, you don't have to bundle boto3 when deploying your Lambda application. It is already present in the Lambda python execution environment. Feel free to remove boto3 from your requirements.txt .

Note that AWS recommends you bundle your own as the one in Lambda might not be fully up-to-date, but that matters only if you want to use the very latest feature or services of AWS. I've been using the bundled one for over 2 years and haven't had an issue once.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM