Zappa: Error when deploying API Gateway: A GET request to '/' yielded a 502 response code.

I’m trying to deploy to AWS for the first time using Zappa. I have a Django API running in a virtual environment I created using virtualenvwrapper.

When I ran zappa deploy and now when I run zappa update, it seems to go okay - it downloads and installs dependencies, zips the project, uploads it, uploads the Lambda code and then tries to deploy the API Gateway. That’s when it fails and I get the following: Unscheduled chatroomserver-dev-zappa-keep-warm-handler.keep_warm_callback. Scheduled chatroomserver-dev-zappa-keep-warm-handler.keep_warm_callback with expression rate(4 minutes)! Error: Warning! Status check on the deployed lambda failed. A GET request to '/' yielded a 502 response code.

It’s a super simple chat API, I pushed it here: https://github.com/michaloslav/Chatroom-Backend (I didn’t push ChatroomServer/settings.py because it includes databases access information so if you try to run it, it won’t work)

Environment: Zappa version: 0.48.2 Win 10, Python 3.7 Pip freeze output: argcomplete==1.9.3 astroid==2.2.5 base58==0.2.4 boto3==1.9.185 botocore==1.12.185 certifi==2019.6.16 cfn-flip==1.2.1 chardet==3.0.4 Click==7.0 colorama==0.4.1 dataclasses==0.6 Django==2.2.3 django-cors-headers==3.0.2 django-filter==2.1.0 django-mongodb-engine==0.6.0 djangorestframework==3.9.4 djongo==1.2.33 docutils==0.14 durationpy==0.5 future==0.16.0 handler==1.3.0 hjson==3.0.1 idna==2.8 isort==4.3.21 jmespath==0.9.3 kappa==0.6.0 lambda-packages==0.20.0 lazy-object-proxy==1.4.1 Markdown==3.1.1 mccabe==0.6.1 placebo==0.9.0 pylint==2.3.1 pymongo==3.8.0 python-dateutil==2.6.1 python-slugify==1.2.4 pytz==2019.1 PyYAML==5.1.1 requests==2.22.0 s3transfer==0.2.1 six==1.12.0 sqlparse==0.2.4 toml==0.10.0 tqdm==4.19.1 troposphere==2.4.9 typed-ast==1.4.0 Unidecode==1.1.1 urllib3==1.25.3 Werkzeug==0.15.4 wrapt==1.11.2 wsgi-request-logger==0.4.6 zappa==0.48.2

zappa_settings.json: { "dev": { "aws_region": "us-east-2", "django_settings": "ChatroomServer.settings", "profile_name": "default", "project_name": "chatroomserver", "runtime": "python3.7", "s3_bucket": "michaloslav-chatroom", "extra_permissions": [{ "Effect": "Allow", "Action": ["rekognition:*"], "Resource": "*" }] } }

I already saw some people having similar issues and there seem to be 2 potential solutions:

  1. Running zappa tail and installing any missing dependencies. I tried that and got the following: 1562750236050] [ERROR] Runtime.ImportModuleError: Unable to import module 'handler': No module named 'werkzeug [1562753064340] [ERROR] Runtime.HandlerNotFound: Handler 'lambda_handler' missing on module 'handler' (both of these occured multiple times and there was also some other stuff but it doesn’t seem relevant)

So I pip installed handler, tried upgrading werkzeug which was already up to date and tried installing lambda_handler which doesn’t exist. I tried zappa update again after that and still got the same result 2) Downgrading Zappa to 0.45.1. I tried that but it doesn’t support Python 3.7. If necessary, I could downgrade to Python 3.6, the code should still work. I’m not really sure how that would work though and there should be a way to get it to work without downgrading.

About this issue

  • Original URL
  • State: open
  • Created 5 years ago
  • Reactions: 7
  • Comments: 24 (3 by maintainers)

Most upvoted comments

Sorry about the late reply. The logs are basically these lines all over again and again.

START RequestId: 41f30055-88aa-4be2-af60-eaa13b5ef45d Version: $LATEST

[ERROR] Runtime.HandlerNotFound: Handler 'lambda_handler' missing on module 'handler'

END RequestId: 41f30055-88aa-4be2-af60-eaa13b5ef45d

REPORT RequestId: 41f30055-88aa-4be2-af60-eaa13b5ef45d Duration: 1.47 ms Billed Duration: 100 ms Memory Size: 512 MB Max Memory Used: 53 MB

(The RequestId changes with every request)

It really looks like the lambda_handler thing might be the problem but I have no idea how to fix that. I already installed handler and it’s up to date