Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Serverless hangs when running sls deploy. Docker command not ending

I am following this tutorial in order to setup serverless AWS lambda with python.

I want to run this simple httprequest function (residing in httprequest.py) with serverless lambda:

import requests

def handler(event, context):
    r = requests.get("https://news.ycombinator.com/news")
    return {"content": r.text}

The following is my serveless.yaml:

service: serverlessProj
frameworkVersion: '2'

provider:
  name: aws
  runtime: python3.8

functions:
  hello:
    handler: hello.handler
  httprequest:
    handler: httprequest.handler

plugins:
  - serverless-python-requirements

custom:
  pythonRequirements:
    dockerizePip: true

Now, as you can see, the custom section tells the serverless-python-requirements plugin to compile the Python packages in a Docker container. It should be installing the plugins which are in the requirements.txt. This is the contents of requirements.txt:

requests

When running sls deploy, this is the console output:

Serverless: Generated requirements from /Users/user/Desktop/ShoeSwiper/Serverless/requirements.txt in /Users/user/Desktop/ShoeSwiper/Serverless/.serverless/requirements.txt...
Serverless: Installing requirements from /Users/user/Library/Caches/serverless-python-requirements/007/requirements.txt ...
Serverless: Docker Image: lambci/lambda:build-python3.8
Serverless: Using download cache directory /Users/user/Library/Caches/serverless-python-requirements/downloadCacheslspyc
Serverless: Running docker run --rm -v /Users/user/Library/Caches/serverless-python-requirements/007\:/var/task\:z -v /Users/user/Library/Caches/serverless-python-requirements/downloadCacheslspyc\:/var/useDownloadCache\:z -u 0 lambci/lambda\:build-python3.8 python3.8 -m pip install -t /var/task/ -r /var/task/requirements.txt --cache-dir /var/useDownloadCache...

And then it just stays stuck. Any idea what's wrong. Am I missing something?

like image 286
Antoine Neidecker Avatar asked Aug 31 '25 21:08

Antoine Neidecker


1 Answers

Okay so turns out everything works. The command is not hanging, it just takes a lot of time. Patience is the key.

like image 50
Antoine Neidecker Avatar answered Sep 03 '25 10:09

Antoine Neidecker