Zappa icon indicating copy to clipboard operation
Zappa copied to clipboard

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

Open selimppc opened this issue 5 years ago • 25 comments

I did:

  1. created a IAM with full administrativeAccess
  2. Install Zappa on venv
  3. Init Zappa
  4. Zappa deploy dev

Now getting error. I am confusing with AWS ROLE and Groups as well.

ERROR:

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

Here is the full result:

(venv) selim@sr ms % zappa deploy dev
Calling deploy for stage dev..
Downloading and installing dependencies..
 - typed-ast==1.4.1: Using locally cached manylinux wheel
 - pycrypto==2.6.1: Using precompiled lambda package 
 - psycopg2-binary==2.8.4: Using locally cached manylinux wheel
 - markupsafe==1.1.1: Using locally cached manylinux wheel
 - lazy-object-proxy==1.4.3: Using locally cached manylinux wheel
 - greenlet==0.4.15: Using locally cached manylinux wheel
 - gevent==1.4.0: Using locally cached manylinux wheel
 - cryptography==2.8: Warning! Using precompiled lambda package version 1.9 instead!
 - coverage==5.0.3: Using locally cached manylinux wheel
 - cffi==1.13.2: Using locally cached manylinux wheel
 - sqlite==python3: Using precompiled lambda package
Packaging project as gzipped tarball.
WARNING: Target directory /Users/selim.bongo/Sites/python/ms/handler_venv/lib/python3.6/site-packages/zappa already exists. Specify --upgrade to force replacement.
WARNING: Target directory /Users/selim.bongo/Sites/python/ms/handler_venv/lib/python3.6/site-packages/zappa-0.48.2.dist-info already exists. Specify --upgrade to force replacement.
Downloading and installing dependencies..
 - sqlite==python3: Using precompiled lambda package
Packaging project as zip.
Uploading dev-1580015449.tar.gz (41.0MiB)..
100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 43.0M/43.0M [00:11<00:00, 3.64MB/s]
Uploading handler_dev-1580015525.zip (11.7MiB)..
100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 12.2M/12.2M [00:01<00:00, 6.32MB/s]
Uploading dev-template-1580015553.json (1.6KiB)..
100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 1.66K/1.66K [00:00<00:00, 10.3KB/s]
Waiting for stack dev to create (this can take a bit)..
100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 4/4 [00:09<00:00,  2.81s/res]
Deploying API Gateway..
Error: Warning! Status check on the deployed lambda failed. A GET request to '/' yielded a 500 response code.


selimppc avatar Jan 26 '20 05:01 selimppc

same error getting in a different way:

(venv) selim@sr ms % zappa deploy dev
Calling deploy for stage dev..
Creating ms-dev-ZappaLambdaExecutionRole IAM Role..
Creating zappa-permissions policy on ms-dev-ZappaLambdaExecutionRole IAM Role.
Downloading and installing dependencies..
 - typed-ast==1.4.1: Using locally cached manylinux wheel
 - pycrypto==2.6.1: Using precompiled lambda package 
 - psycopg2-binary==2.8.4: Using locally cached manylinux wheel
 - markupsafe==1.1.1: Using locally cached manylinux wheel
 - lazy-object-proxy==1.4.3: Using locally cached manylinux wheel
 - greenlet==0.4.15: Using locally cached manylinux wheel
 - gevent==1.4.0: Using locally cached manylinux wheel
 - cryptography==2.8: Warning! Using precompiled lambda package version 1.9 instead!
 - coverage==5.0.3: Using locally cached manylinux wheel
 - cffi==1.13.2: Using locally cached manylinux wheel
 - sqlite==python3: Using precompiled lambda package
Packaging project as zip.
Uploading ms-dev-1580017052.zip (39.4MiB)..
100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 41.3M/41.3M [00:10<00:00, 3.94MB/s]
Scheduling..
Scheduled 27f04aa0e0e79b6dacd35f42d28e773800dd4-handler.keep_warm_callback with expression rate(4 minutes)!
Uploading ms-dev-template-1580017094.json (1.6KiB)..
100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 1.67K/1.67K [00:00<00:00, 9.91KB/s]
Waiting for stack ms-dev to create (this can take a bit)..
 75%|████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████▊                                        | 3/4 [00:09<00:04,  5.00s/res]
Deploying API Gateway..
Error: Warning! Status check on the deployed lambda failed. A GET request to '/' yielded a 502 response code.

LOG is here

Calling tail for stage dev..
[1580017110352] Instancing..
[1580017112990] bcrypt is required to use Flask-Bcrypt
[1580017113009] /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 4, in <module>
  from app import app, manager
  File "/var/task/app/__init__.py", line 11, in <module>
  from flask_bcrypt import Bcrypt
  File "/var/task/flask_bcrypt.py", line 27, in <module>
  raise e
  File "/var/task/flask_bcrypt.py", line 24, in <module>
  import bcrypt
  File "/var/task/bcrypt/__init__.py", line 25, in <module>
  from . import _bcrypt
ImportError: /var/task/bcrypt/_bcrypt.abi3.so: invalid ELF header
[1580017114837] Instancing..
[1580017117531] bcrypt is required to use Flask-Bcrypt
[1580017117532] /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 4, in <module>
  from app import app, manager
  File "/var/task/app/__init__.py", line 11, in <module>
  from flask_bcrypt import Bcrypt
  File "/var/task/flask_bcrypt.py", line 27, in <module>
  raise e
  File "/var/task/flask_bcrypt.py", line 24, in <module>
  import bcrypt
  File "/var/task/bcrypt/__init__.py", line 25, in <module>
  from . import _bcrypt
ImportError: /var/task/bcrypt/_bcrypt.abi3.so: invalid ELF header
[1580017178188] [DEBUG] 2020-01-26T05:39:38.188Z 2fc73add-81de-42f2-9d41-a1a40fbf6f15 Zappa Event: {'time': '2020-01-26T05:38:16Z', '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': '283d75bd-f15d-24fa-c8ee-4b065c74af0c', 'kwargs': {}}
[1580017178188] [DEBUG] 2020-01-26T05:39:38.188Z 2fc73add-81de-42f2-9d41-a1a40fbf6f15 Zappa Event: {}

selimppc avatar Jan 26 '20 05:01 selimppc

Hello,

A long shot:

The error seems to be relating with the "compilation incompatibility" of the library bcrypt. Lambda function OS is Unix-like (Amazon Linux) but perhaps you have compiled (or you are using an already compiled) the bcrypt.so in Windows environment. So probably you need to find the appropriate compiled version of the library to suit the Linux based OS of the Lambda function.

This article was the source of above inspiration: invalid ELF header

aralmpa avatar Jan 26 '20 19:01 aralmpa

Hi -

I hope to assist here since I had the same issue and found the source of it -> and the right solution.

The main issue is that there are indeed precompiled libraries we use - mainly psycopg2. This one is not working in Lambda - hence you should include instead aws-psycopg2.

@jneves - I hope this could assist with future releases. I guess a possible warning during Zappa init or to include this in the precompiled libraries. Of course, if I can assist with anything myself, please let me know!

dudil avatar Apr 06 '20 08:04 dudil

My Error Breakpoint for reference:

Calling deploy for stage dev..
Downloading and installing dependencies..
 - typed-ast==1.4.1: Downloading
100%|████████████████████████████████████████████████████████████████████████████████| 738k/738k [00:00<00:00, 2.43MB/s]
 - markupsafe==1.1.1: Downloading
100%|██████████████████████████████████████████████████████████████████████████████| 27.5k/27.5k [00:00<00:00, 1.83MB/s]
 - lazy-object-proxy==1.4.3: Downloading
100%|██████████████████████████████████████████████████████████████████████████████| 56.5k/56.5k [00:00<00:00, 1.78MB/s]
Packaging project as zip.
Uploading capp-dev-1587298017.zip (11.5MiB)..
100%|███████████████████████████████████████████████████████████████████████████████| 12.0M/12.0M [00:36<00:00, 329kB/s]
Scheduling..
Scheduled capp-dev-zappa-keep-warm-handler.keep_warm_callback with expression rate(4 minutes)!
Uploading capp-dev-template-1587298074.json (1.6KiB)..
100%|██████████████████████████████████████████████████████████████████████████████| 1.59k/1.59k [00:00<00:00, 1.72kB/s]
Waiting for stack capp-dev to create (this can take a bit)..
 75%|███████████████████████████████████████████████████████████████                     | 3/4 [00:13<00:04,  4.57s/res]
Deploying API Gateway..
Error: Warning! Status check on the deployed lambda failed. A GET request to '/' yielded a 500 response code.

sagun786 avatar Apr 19 '20 12:04 sagun786

@sagun786 remove Flask-Bcrypt if you use in your app

selimppc avatar Apr 19 '20 13:04 selimppc

(venv) maitrayee@maitrayee-HP-250-G7-Notebook-PC:~/Documents/building-api-django$ zappa update dev Calling update for stage dev.. Downloading and installing dependencies.. Packaging project as zip. Uploading pollsapi-dev-1587365896.zip (1.8MiB).. 100%|███████████████████████████████████████| 1.91M/1.91M [00:12<00:00, 156kB/s] Updating Lambda function code.. Updating Lambda function configuration.. Uploading pollsapi-dev-template-1587365914.json (1.6KiB).. 100%|██████████████████████████████████████| 1.61k/1.61k [00:00<00:00, 1.68kB/s] Deploying API Gateway.. Scheduling.. Unscheduled pollsapi-dev-zappa-keep-warm-handler.keep_warm_callback. Scheduled pollsapi-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.

Now what to do? I ran pip3 freeze . there is no bcrypt.

utkarshconnectbud avatar Apr 20 '20 07:04 utkarshconnectbud

@maitrayeeconnectbud please check your log

you can check log from your PC :

$ zappa tail 

it's indicating the issue with API gateway . can you share your zappa_config file ?

selimppc avatar Apr 20 '20 11:04 selimppc

I got this error too and the log tails indicated that Runtime.ImportModuleError: Unable to import module 'handler': No module named 'werkzeug'

I checked my pyenv virtual enviroment carefully and I am sure that this werkzeug package is included in my virtual environment site package. Please tell me if I was missed any crucial things about installation or configuration.

hoangpham-brainstech avatar Apr 22 '20 14:04 hoangpham-brainstech

for testing comment this one werkzeug wherever you use.

selimppc avatar Apr 23 '20 04:04 selimppc

same issue here, 502 error when checking gateway status. project doesn't use wekzeug but it is a zappa dependency apparently. have tried downgrading through versions to zappa 0.48.0 but still same error, looks like AWS may have changed something ?

bharling avatar Apr 23 '20 20:04 bharling

my zappa_settings... this is working perfectly. :

"dev": {
    "s3_bucket": "project-dev",
    "app_function": "manage.app",
    "profile_name": "default",
    "project_name": "projectName",
    "runtime": "python3.6",
    "aws_region": "ap-...........-1",
    "apigateway_enabled": false,
    "manage_roles": false,
    "role_name": "ZappaPythonRole",
    "role_arn": "arn:aws:iam::1234567890:role/ZappaPythonRole",
    "delete_s3_zip": false,
    }

selimppc avatar Apr 24 '20 04:04 selimppc

For me it was 100% related to bcrypt on mac. I wish I was better at pip and python to understand what is going on but I instead deployed from my linux machine without a problem.

On my mac i added "apigateway_enabled": false, to my zappa_config and that did fix error Error: Warning! Status check on the deployed lambda failed. A GET request to '/' yielded a 500 that i was seeing when running zappa update, however all of my endpoints were failing with the following error:

"{'message': 'An uncaught exception happened while servicing this request. You can investigate this with the zappa tail command.', 'traceback': ['Traceback (most recent call last):\n', ' File "/var/task/handler.py", line 540, in handler\n with Response.from_app(self.wsgi_app, environ) as response:\n', ' File "/var/task/werkzeug/wrappers/base_response.py", line 287, in from_app\n return cls(*_run_wsgi_app(app, environ, buffered))\n', ' File "/var/task/werkzeug/test.py", line 1119, in run_wsgi_app\n app_rv = app(environ, start_response)\n', "TypeError: 'NoneType' object is not callable\n"]}"

The only way i was able to fix this was to instead deploy from a linux machine. I strongly suggest checking the cloud watch logs instead of zappa tail because it provided information which helped me leaod to this conclusion:

[ERROR] ImportError: /var/task/bcrypt/_bcrypt.abi3.so: invalid ELF header

Im sorry that i dont know how to fix it on mac but I did not have to make any adjustments to my reqs.txt or zappa config for things to work exactly as they should in linux.

Here are my reqs.txt and zappa config for anyone curious

    "test3": {
        "s3_bucket": "MY_BUCKET",
        "app_function": "app.server.server",
        "profile_name": "default",
        "project_name": "MY_PROJECT",
        "runtime": "python3.7",
        "aws_region": "us-east-1",
	"cors": true
    }
argcomplete==1.11.1
aws-shell==0.2.1
awscli==1.18.51
bcrypt==3.1.7
bleach==3.1.1
boto3==1.13.1
botocore==1.16.1
bson==0.5.8
cerami==0.1.7
certifi==2019.11.28
cffi==1.13.2
cfn-flip==1.2.3
chardet==3.0.4
Click==7.0
colorama==0.4.3
configobj==5.0.6
docutils==0.14
durationpy==0.5
Flask==1.1.1
Flask-Cors==3.0.8
Flask-Script==2.0.6
future==0.18.2
hjson==3.0.1
idna==2.9
importlib-metadata==1.5.0
itsdangerous==1.1.0
Jinja2==2.11.0
jmespath==0.9.4
kappa==0.6.0
keyring==21.1.1
lxml==4.3.4
MarkupSafe==1.1.1
mock==3.0.5
pip-tools==5.1.1
pkginfo==1.5.0.1
placebo==0.9.0
prompt-toolkit==1.0.18
pyasn1==0.4.8
pycparser==2.19
Pygments==2.6.1
PyJWT==1.7.1
python-dateutil==2.6.1
python-slugify==4.0.0
PyYAML==5.3.1
readme-renderer==24.0
requests==2.23.0
requests-toolbelt==0.9.1
rsa==3.4.2
s3transfer==0.3.0
six==1.12.0
text-unidecode==1.3
toml==0.10.0
tqdm==4.43.0
troposphere==2.6.0
twine==3.1.1
urllib3==1.25.3
wcwidth==0.1.8
webencodings==0.5.1
Werkzeug==0.16.1
wsgi-request-logger==0.4.6
zappa==0.51.0
zipp==3.1.0

gummybuns avatar May 02 '20 05:05 gummybuns

@gummybuns

For this error: invalid ELF header

please use python-jose to decode your token. ( https://pypi.org/project/python-jose/ ) This will help in lambda

selimppc avatar May 02 '20 05:05 selimppc

@selimppc @selimppc If apigateway_enabled is set to false(in the zappa settings.json), even though the app is successfully deployed and it does outputs the success message: "Your deployment is live.." but there is no api-url and if it is commeted out or set to true it throws "Error: Warning! Status check on the deployed lambda failed. A GET request to '/' yielded a 502 response code." error.

ghost avatar May 08 '20 10:05 ghost

@valkczr yes, it is because of your IAM / role permission issue.

For testing allow administrative full access for the role or IAM. Then you will get live URL

selimppc avatar May 08 '20 10:05 selimppc

@selimppc Thanks !! worked!!

ghost avatar May 08 '20 12:05 ghost

I am facing the same issue for deployed lambda failed

Sharing my response from zappa tail below for reference:

(.env) ✘  first_project/src   blog ●  zappa tail (pip 9.0.1 (/mnt/c/Users/demo_user/workdir/Develop/PythonDev/Django/first_project/.env/lib/python3.6/site-packages), Requirement.parse('pip>=20.0'), {'pip-tools'}) Calling tail for stage dev.. [1600320268382] Instancing.. [1600320270426] base dir path /var/task [1600320271226] [DEBUG] 2020-09-17T05:24:31.225Z 45e51974-312e-4557-bd92-56392b766d49 Using selector: EpollSelector [1600320271625] SQLite 3.8.3 or later is required (found 3.7.17).: ImproperlyConfigured Traceback (most recent call last): File "/var/task/handler.py", line 609, in lambda_handler return LambdaHandler.lambda_handler(event, context) File "/var/task/handler.py", line 240, in lambda_handler handler = cls() File "/var/task/handler.py", line 146, in init wsgi_app_function = get_django_wsgi(self.settings.DJANGO_SETTINGS) File "/var/task/zappa/ext/django_zappa.py", line 20, in get_django_wsgi return get_wsgi_application() File "/var/task/django/core/wsgi.py", line 12, in get_wsgi_application django.setup(set_prefix=False) File "/var/task/django/init.py", line 24, in setup apps.populate(settings.INSTALLED_APPS) File "/var/task/django/apps/registry.py", line 114, in populate app_config.import_models() File "/var/task/django/apps/config.py", line 211, in import_models self.models_module = import_module(models_module_name) File "/var/lang/lib/python3.6/importlib/init.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "", line 994, in _gcd_import File "", line 971, in _find_and_load File "", line 955, in _find_and_load_unlocked File "", line 665, in _load_unlocked File "", line 678, in exec_module File "", line 219, in _call_with_frames_removed File "/var/task/django/contrib/auth/models.py", line 2, in from django.contrib.auth.base_user import AbstractBaseUser, BaseUserManager File "/var/task/django/contrib/auth/base_user.py", line 47, in class AbstractBaseUser(models.Model): File "/var/task/django/db/models/base.py", line 121, in new new_class.add_to_class('_meta', Options(meta, app_label)) File "/var/task/django/db/models/base.py", line 325, in add_to_class value.contribute_to_class(cls, name) File "/var/task/django/db/models/options.py", line 208, in contribute_to_class self.db_table = truncate_name(self.db_table, connection.ops.max_name_length()) File "/var/task/django/db/init.py", line 28, in getattr return getattr(connections[DEFAULT_DB_ALIAS], item) File "/var/task/django/db/utils.py", line 207, in getitem backend = load_backend(db['ENGINE']) File "/var/task/django/db/utils.py", line 111, in load_backend return import_module('%s.base' % backend_name) File "/var/lang/lib/python3.6/importlib/init.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "/var/task/django/db/backends/sqlite3/base.py", line 68, in check_sqlite_version() File "/var/task/django/db/backends/sqlite3/base.py", line 65, in check_sqlite_version raise ImproperlyConfigured('SQLite 3.8.3 or later is required (found %s).' % Database.sqlite_version) django.core.exceptions.ImproperlyConfigured: SQLite 3.8.3 or later is required (found 3.7.17). [1600320279208] [DEBUG] 2020-09-17T05:24:39.208Z 4b2053a8-2e2e-4918-8646-566733819d3e Zappa Event: {'time': '2020-09-17T05:23:53Z', 'detail-type': 'Scheduled Event', 'source': 'aws.events', 'account': '443595740391', 'region': 'eu-west-3', 'detail': {}, 'version': '0', 'resources': ['arn:aws:events:eu-west-3:443595740391:rule/src-dev-zappa-keep-warm-handler.keep_warm_callback'], 'id': 'a8a0c714-153d-d150-845d-cc683261ec37', 'kwargs': {}} [1600320279208] [DEBUG] 2020-09-17T05:24:39.208Z 4b2053a8-2e2e-4918-8646-566733819d3e Zappa Event: {} [1600320519249] [DEBUG] 2020-09-17T05:28:39.249Z 2aa8b430-dfa6-4a4e-b399-652480a6f633 Zappa Event: {'time': '2020-09-17T05:27:53Z', 'detail-type': 'Scheduled Event', 'source': 'aws.events', 'account': '443595740391', 'region': 'eu-west-3', 'detail': {}, 'version': '0', 'resources': ['arn:aws:events:eu-west-3:443595740391:rule/src-dev-zappa-keep-warm-handler.keep_warm_callback'], 'id': '57497f81-4bb6-51bb-9469-c781de1dcae9', 'kwargs': {}} [1600320519250] [DEBUG] 2020-09-17T05:28:39.250Z 2aa8b430-dfa6-4a4e-b399-652480a6f633 Zappa Event: {}

ghost avatar Sep 17 '20 05:09 ghost

Response code from my zappa deploy dev

(.env) first_project/src   blog ●  zappa deploy dev (pip 9.0.1 (/mnt/c/Users/demo_user/workdir/Develop/PythonDev/Django/first_project/.env/lib/python3.6/site-packages), Requirement.parse('pip>=20.0'), {'pip-tools'}) Calling deploy for stage dev.. Creating src-dev-ZappaLambdaExecutionRole IAM Role.. Creating zappa-permissions policy on src-dev-ZappaLambdaExecutionRole IAM Role.

Downloading and installing dependencies..

  • typed-ast==1.4.1: Downloading 100%|████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 738k/738k [00:00<00:00, 2.92MB/s] - pillow==7.1.2: Downloading 100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 2.12M/2.12M [00:01<00:00, 1.36MB/s] - lazy-object-proxy==1.4.3: Downloading 100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 55.6k/55.6k [00:00<00:00, 483kB/s] - cryptography==3.1: Downloading 100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 2.62M/2.62M [00:00<00:00, 4.93MB/s] - cffi==1.14.2: Downloading 100%|████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 401k/401k [00:00<00:00, 1.32MB/s]Packaging project as zip. Uploading src-dev-1600319828.zip (25.6MiB).. 100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 26.8M/26.8M [00:13<00:00, 2.05MB/s]Scheduling.. Scheduled src-dev-zappa-keep-warm-handler.keep_warm_callback with expression rate(4 minutes)! Uploading src-dev-template-1600320233.json (1.5KiB).. 100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 1.58k/1.58k [00:00<00:00, 3.82kB/s]Waiting for stack src-dev to create (this can take a bit).. 75%|█████████████████████████████████████████████████████████████████████████████████████████████ | 3/4 [00:10<00:03, 3.35s/res]Deploying API Gateway.. Error: Warning! Status check on the deployed lambda failed. A GET request to '/' yielded a 502 response code.

ghost avatar Sep 17 '20 05:09 ghost

tail reports an issue with SQLite 3.8.3 .... do I need to update the version ??

ghost avatar Sep 17 '20 05:09 ghost

[1600320271625] SQLite 3.8.3 or later is required (found 3.7.17).: ImproperlyConfigured

I dont use Django, but it looks like it is expecting a different version than what is available. From what I understand, Lambda function are run in Amazon's Linux OS and you would be limited to the dependencies that operating system provides. I am not positive but i dont think you can specify a sqlite version in pip.

Also, without having any idea on what you are using sqlite for, im guessing it is your database for your django application? I dont know how that would work with lambda, I guess you store the database in s3 somehow? If you are using sqlite for your database, you might want to consider an alternative that allows for remote connections.

Best of luck!

gummybuns avatar Sep 18 '20 02:09 gummybuns

I can try using the SQLite3 version that it requires, and update here again.

ghost avatar Sep 18 '20 02:09 ghost

In case it helps anybody: I spent hours wrestling with the same error message debugging a Flask application deployed to AWS Lambda and after lots of trial and error the solution in my case was to pip install flask into the same environment as zappa.

bast avatar Mar 13 '21 18:03 bast

I faced the same problem where I was trying to deploy the lambda from mac os machine but had the same invalid ELF header issue. Finally what helped me a short summary

$ docker pull lambci/lambda:build-python3.8
$ alias zappashell='docker run -ti -e AWS_PROFILE=<aws-profile-name> -v "$(pwd):/var/task" -v ~/.aws/:/root/.aws  --rm lambci/lambda:build-python3.8 bash'
$ alias zappashell >> ~/.bash_profile
$ cd /your_zappa_project
$ zappashell
bash-4.2# virtualenv env
$ source env/bin/activate
$ pip install -r requirement.txt
$ <your-deploy-command>

reference: https://romandc.com/zappa-django-guide/setup/#approach-2-docker-with-zappa-recommended

dh-saurabh avatar Oct 12 '21 15:10 dh-saurabh

my zappa_settings... this is working perfectly. :

"dev": {
    "s3_bucket": "project-dev",
    "app_function": "manage.app",
    "profile_name": "default",
    "project_name": "projectName",
    "runtime": "python3.6",
    "aws_region": "ap-...........-1",
    "apigateway_enabled": false,
    "manage_roles": false,
    "role_name": "ZappaPythonRole",
    "role_arn": "arn:aws:iam::1234567890:role/ZappaPythonRole",
    "delete_s3_zip": false,
    }

This is right. You have to configure the zappa_settings.json file correctly. I am not sure which line you need to include. The app_function needs to be correct.

basillatif avatar Mar 31 '22 16:03 basillatif

my zappa_settings... this is working perfectly. :

"dev": {
    "s3_bucket": "project-dev",
    "app_function": "manage.app",
    "profile_name": "default",
    "project_name": "projectName",
    "runtime": "python3.6",
    "aws_region": "ap-...........-1",
    "apigateway_enabled": false,
    "manage_roles": false,
    "role_name": "ZappaPythonRole",
    "role_arn": "arn:aws:iam::1234567890:role/ZappaPythonRole",
    "delete_s3_zip": false,
    }

Thank you for your solution. If i leave it as "apigateway_enabled": false, will it have any effect or error?

nguyenorlab avatar May 26 '22 08:05 nguyenorlab

Try to configure aws IAM: user name, group name, role name, role policy, ARN, bucket, region, ID USER, etc

Link tutorial2 https://pythonforundergradengineers.com/deploy-serverless-web-app-aws-lambda-zappa.html#what-is-zappa

https://medium.com/velotio-perspectives/deploy-serverless-event-driven-python-applications-using-zappa-8e215e7f2c5f


This are fake custom data about user CREDENTIALS. You will use your data.

s3 bucket53534 zappa user name: zappa_user id zappa_user: 235435435435 zappa_user Access key HG798CG04704 zappa_user Access key VGF98769hfghgjf/ge876ge089

zappa group name: zappa_group zappa_role: "ZappaPythonRole", "role_arn": "arn:aws:iam::235435435435:role/ZappaPythonRole", "app_function": "app.app", "profile_name": "default", "project_name": "zappa-flask-app", "runtime": "python3.9", "s3_bucket": "bucket53534", "aws_region": "eu-west-1" #alternative "aws_region": "us-west-2"

#ARN #Amazon Resource Names #arn:aws:iam::235435435435:user/zappa_user #arn:aws:iam::235435435435:role/ZappaPythonRole #arn:aws:s3:::bucket53534

aws admin user access key BHK8TTTTTTTTTT aws admin user secret access key kkhg098g07gg7giiiiiiiiiiii


#configure zappa_settings.json

directory: /home/user001/mydir/python3_9/zappa_awsserverless_001/flask-zappa-tutorial

files: LICENSE README.md pycache app.py aws requirements.txt zappa_security_policy.json zappa_settings.bkp1.json zappa_settings.json

{ "dev": { "apigateway_enabled": false, "manage_roles": false, "role_name": "ZappaPythonRole", "role_arn": "arn:aws:iam::235435435435:role/ZappaPythonRole", "delete_s3_zip": false, "app_function": "app.app", "profile_name": "default", "project_name": "zappa-flask-app", "runtime": "python3.9", "s3_bucket": "bucket53534", "aws_region": "eu-west-1" } }


#CONFIGURE AWS in the bash shell

#step A. install apt install curl -y curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip" apt install unzip -y unzip awscliv2.zip ./aws/install

#step B. configure

aws configure access key BHK8TTTTTTTTTT secret access key kkhg098g07gg7giiiiiiiiiiii eu-west-1 json


#configure aws IAM: user name, group name, role name, role policy

#about group name https://us-east-1.console.aws.amazon.com/iamv2/home?region=eu-west-1#/groups group: zappa_group


#about user name https://us-east-1.console.aws.amazon.com/iamv2/home?region=eu-west-1#/users user: zappa_user


#about user id keys #generate user id keys

https://us-east-1.console.aws.amazon.com/iamv2/home?region=eu-west-1#/users/details/zappa_user?section=permissions

https://us-east-1.console.aws.amazon.com/iamv2/home?region=eu-west-1#/users/details/zappa_user/create-access-key

zappa_user Access key HG798CG04704 Access key VGF98769hfghgjf/ge876ge089


#about role name https://us-east-1.console.aws.amazon.com/iamv2/home?region=eu-west-1#/roles

https://us-east-1.console.aws.amazon.com/iamv2/home?region=eu-west-1#/roles/details/ZappaPythonRole?section=permissions

PythonRole?section=permissions

role: ZappaPythonRole


#about role (ZappaPythonRole) Trust Relationships tab https://us-east-1.console.aws.amazon.com/iamv2/home?region=eu-west-1#/roles/details/ZappaPythonRole?section=trust_relationships

{ "Version": "2012-10-17", "Statement": [ { "Sid": "", "Effect": "Allow", "Principal": { "Service": [ "lambda.amazonaws.com", "apigateway.amazonaws.com", "events.amazonaws.com" ] }, "Action": "sts:AssumeRole" } ] }


#about permission policy

Link for user id 235435435435

https://us-east-1.console.aws.amazon.com/iamv2/home?region=eu-west-1#/policies/details/arn%3Aaws%3Aiam%3A%3A235435435435%3Apolicy%2Fzappa_policy/edit/v1/?step=modifyPermissions

#we need thE above defined data ARN ETC #arn:aws:iam::235435435435:user/zappa_user #arn:aws:iam::235435435435:role/ZappaPythonRole #arn:aws:s3:::bucket53534

{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "iam:AttachRolePolicy", "iam:GetRole", "iam:CreateRole", "iam:PassRole", "iam:PutRolePolicy" ], "Resource": [ "arn:aws:iam::235435435435:role/-ZappaLambdaExecutionRole", "arn:aws:iam::235435435435:role/ZappaPythonRole" ] }, { "Effect": "Allow", "Action": [ "apigateway:DELETE", "apigateway:GET", "apigateway:PATCH", "apigateway:POST", "apigateway:PUT", "events:DeleteRule", "events:DescribeRule", "events:ListRules", "events:ListRuleNamesByTarget", "events:ListTargetsByRule", "events:PutRule", "events:PutTargets", "events:RemoveTargets", "lambda:AddPermission", "lambda:CreateFunction", "lambda:DeleteFunction", "lambda:GetAlias", "lambda:GetFunction", "lambda:GetFunctionConfiguration", "lambda:GetPolicy", "lambda:InvokeFunction", "lambda:DeleteFunctionConcurrency", "lambda:ListVersionsByFunction", "lambda:RemovePermission", "lambda:UpdateFunctionCode", "lambda:UpdateFunctionConfiguration", "cloudformation:CreateStack", "cloudformation:DeleteStack", "cloudformation:DescribeStackResource", "cloudformation:DescribeStacks", "cloudformation:ListStackResources", "cloudformation:UpdateStack", "cloudfront:UpdateDistribution", "logs:DeleteLogGroup", "logs:DescribeLogStreams", "logs:FilterLogEvents", "route53:ListHostedZones" ], "Resource": [ "" ] }, { "Effect": "Allow", "Action": [ "s3:CreateBucket", "s3:ListBucket", "s3:ListBucketMultipartUploads" ], "Resource": [ "arn:aws:s3:::bucket53534" ] }, { "Effect": "Allow", "Action": [ "s3:DeleteObject", "s3:GetObject", "s3:PutObject", "s3:AbortMultipartUpload", "s3:ListMultipartUploadParts" ], "Resource": [ "arn:aws:s3:::bucket53534/*" ] } ] }

############################ check

https://eu-west-1.console.aws.amazon.com/lambda/home?region=eu-west-1#/functions

https://eu-west-1.console.aws.amazon.com/apigateway/main/apis?region=eu-west-1

kenny1323 avatar Aug 18 '23 23:08 kenny1323

Hi @kenny1323 and others, The new zappa official library is here, and you can join the slack channel here

souravjamwal77 avatar Aug 19 '23 05:08 souravjamwal77