pythonflaskaws-lambdaaws-serverlesszappa

Zappa deploy error deployed lambda failed. A GET request to '/' yielded a 502 response code


I have zappa setting json (zappa_settings.json) as below:

{
    "dev": {
        "app_function": "manage.app",
        "aws_region": "ap-southeast-1",
        "profile_name": "default",
        "project_name": "digital-agency-ms",
        "runtime": "python3.6",
        "s3_bucket": "lambda.com",
        "use_precompiled_packages": false
    }
}

I run my application in local by the command python manage.py run

here is my manage.py :

"""Manage all command related to the micro-service."""
import unittest
import time
from app import app, manager


@manager.command
def run():
    """Run the app."""
    app.run(host='0.0.0.0')


@app.route('/')
def index():
    return "Hooray, you catch me !", 200


if __name__ == '__main__':
    manager.run()

when I run zappa deploy dev it returns 502 response error ERROR showing :

Error: Warning! Status check on the deployed lambda failed. A GET request to '/' yielded a 502 response code.

here is zappa log :

[DEBUG] 2020-01-26T06:04:49.799Z 977e2eda-d28a-4d6d-9242-8d5e58423154 Zappa Event: {}
[1580018889972] Instancing..
[1580018889975] /var/task/bcrypt/_bcrypt.abi3.so: invalid ELF header: ImportError
Traceback (most recent call last):
  File "/var/task/handler.py", line 602, in lambda_handler
  return LambdaHandler.lambda_handler(event, context)
  File "/var/task/handler.py", line 245, in lambda_handler
  handler = cls()
  File "/var/task/handler.py", line 139, in __init__
  self.app_module = importlib.import_module(self.settings.APP_MODULE)
  File "/var/lang/lib/python3.6/importlib/__init__.py", line 126, in import_module
  return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 994, in _gcd_import
  File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 678, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/var/task/manage.py", line 2, in <module>
  import bcrypt
  File "/var/task/bcrypt/__init__.py", line 25, in <module>
  from bcrypt import _bcrypt
ImportError: /var/task/bcrypt/_bcrypt.abi3.so: invalid ELF header
[1580018929896] [DEBUG] 2020-01-26T06:08:49.896Z eb0e51bc-f741-46ff-b0e0-eddccef0b70e Zappa Event: {'time': '2020-01-26T06:08:38Z', 'detail-type': 'Scheduled Event', 'source': 'aws.events', 'account': '906846634189', 'region': 'ap-southeast-1', 'detail': {}, 'version': '0', 'resources': ['arn:aws:events:ap-southeast-1:906846634189:rule/27f04aa0e0e79b6dacd35f42d28e773800dd4-handler.keep_warm_callback'], 'id': 'bb44e9ee-095a-1ae0-6597-ebafee0f4186', 'kwargs': {}}

what is the option - I am missing?


Solution

  • Fixed this issue by removing the package

      Flask-Bcrypt==0.7.1
    

    from requirements.txt

    reinstall packages