I'm trying to use a zip file created with zappa package instead of zappa deploy to match my CI/CD process.
AWS Lambda settings:
Runtime: Python 3.9
Handler: handler.lambda_handler
Architecture: x86_64
When I access the HTTP endpoint, it always returns null in the browser.
I created a Django project. It's a basic project, and you can check this project on the following GitHub repository. https://github.com/hongmingu/zappa1sample
I used the zappa package dev command to create a zip file and uploaded it to S3. Then, I set the S3 URL as the source in AWS Lambda.
Here's my zappa_settings.json file:
{ "dev": { "aws_region": "ap-northeast-2", "django_settings": "zappa1sample.settings", "project_name": "zappa1sample", "runtime": "python3.9", "s3_bucket": "lambda-saver12123" }, "production": { "aws_region": "ap-northeast-2", "django_settings": "zappa1sample.settings", "project_name": "zappa1sample", "runtime": "python3.9", "s3_bucket": "lambda-saver12123" } }
AWS CloudWatch logs are as follows:
INIT_START Runtime Version: python:3.9.v19 Runtime Version ARN: arn:aws:lambda:ap-northeast-2::runtime:e73d5f60c4282fb09ce24a6d3fe8997789616f3a53b903f4ed7c9132a58045f6
START RequestId: ae67fca5-6afa-4a2c-a920-2440bae5af2b Version: $LATEST
Instancing..
[DEBUG] 2023-04-19T07:44:36.009Z ae67fca5-6afa-4a2c-a920-2440bae5af2b Zappa Event: {'version': '2.0', 'routeKey': '$default', 'rawPath': '/', 'rawQueryString': '', 'headers': {'sec-fetch-mode': 'navigate', 'x-amzn-tls-version': 'TLSv1.2', 'sec-fetch-site': 'cross-site', 'accept-language': 'ko-KR,ko;q=0.9,en-US;q=0.8,en;q=0.7,ar;q=0.6,zh-CN;q=0.5,zh;q=0.4', 'x-forwarded-proto': 'https', 'x-forwarded-port': '443', 'x-forwarded-for': '222.111.140.167', 'sec-fetch-user': '?1', 'accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7', 'x-amzn-tls-cipher-suite': 'ECDHE-RSA-AES128-GCM-SHA256', 'sec-ch-ua': '"Chromium";v="112", "Google Chrome";v="112", "Not:A-Brand";v="99"', 'sec-ch-ua-mobile': '?0', 'x-amzn-trace-id': 'Root=1-643f9be1-1f1cb40742c78d566ab0c546', 'sec-ch-ua-platform': '"macOS"', 'host': 'wzzdsza2liopkemzy7h4q3okyu0gsusx.lambda-url.ap-northeast-2.on.aws', 'upgrade-insecure-requests': '1', 'accept-encoding': 'gzip, deflate, br', 'sec-fetch-dest': 'document', 'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/112.0.0.0 Safari/537.36'}, 'requestContext': {'accountId': 'anonymous', 'apiId': 'wzzdsza2liopkemzy7h4q3okyu0gsusx', 'domainName': 'wzzdsza2liopkemzy7h4q3okyu0gsusx.lambda-url.ap-northeast-2.on.aws', 'domainPrefix': 'wzzdsza2liopkemzy7h4q3okyu0gsusx', 'http': {'method': 'GET', 'path': '/', 'protocol': 'HTTP/1.1', 'sourceIp': '222.111.140.167', 'userAgent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/112.0.0.0 Safari/537.36'}, 'requestId': 'ae67fca5-6afa-4a2c-a920-2440bae5af2b', 'routeKey': '$default', 'stage': '$default', 'time': '19/Apr/2023:07:44:33 +0000', 'timeEpoch': 1681890273921}, 'isBase64Encoded': False}
END RequestId: ae67fca5-6afa-4a2c-a920-2440bae5af2b
REPORT RequestId: ae67fca5-6afa-4a2c-a920-2440bae5af2b Duration: 1504.95 ms Billed Duration: 1505 ms Memory Size: 1024 MB Max Memory Used: 84 MB Init Duration: 480.31 ms
It keeps repeating like this, but the browser screen only shows the word null.
Just in case, I unzipped the zip file packaged with Zappa and found handler.lambda_handler as follows:
def lambda_handler(event, context): # pragma: no cover
return LambdaHandler.lambda_handler(event, context)
The returned LambdaHandler class can be found at the following address: https://github.com/Miserlou/Zappa/blob/master/zappa/handler.py
What should I do to solve this issue? Please help.