Container Image runs fine with AWS Lambda Runtime Interface Emulator, but 502 on zappa deploy
See original GitHub issueContext
I followed the steps here to create a container image, upload it to ECR, and run zappa deploy -d
. All routes work perfectly when I test out the image with the AWS Runtime Interface Emulator, i.e, curl -XPOST "http://localhost:9000/2015-03-31/functions/function/invocations" -d '{"path": "/", "httpMethod": "GET", "requestContext": {}, "body": null}'
, but zappa deploy -d
throws me a 502 error. I’ve run zappa tail
, but all I see there is [1659730496257] 'NoneType' object is not callable
.
Unfortunately I’m not cleared by my company to release more than the settings.json file here, but happy to share more details privately.
I have a few questions:
- How is it possible that the image works when being tested on the runtime interface emulator, but fails during deployment? I’ve rewritten the settings file and made sure that
slim_handler
is set to false as well. - Are there any suggestions on where to embed print statements in the handler.py to make zappa tail more informative during debugging?
- Given that I’m deploying this as a docker image, I am not using a venv, and invoking zappa from my project’s conda environment. Could this be the root of any issues?
Expected Behavior
zappa deploy -d
executes successfully and returns the API endpoint.
Actual Behavior
- NoneType object is not callable. Same message replicated in zappa tail. But the same image works when tested with the AWS local Runtime Interface Emulator
Your Environment
- Zappa version used: 0.55.0
- Operating System and Python version: macOS 12.4 Monterrey, Python 3.9
- The output of
pip freeze
: Running everything in docker, so shouldn’t be an issue - Link to your project (optional):
- Your
zappa_settings.json
: { “lambda_docker_flask”: { “app_function”: “server.app”, “project_name”: “app”, “lambda_description”: “Zappa + Docker + Flask” } }
Issue Analytics
- State:
- Created a year ago
- Comments:7
Top Results From Across the Web
Container Image runs fine with AWS Lambda Runtime Interface ...
zappa /Zappa: Container Image runs fine with AWS Lambda Runtime Interface Emulator, but 502 on zappa deploy.
Read more >Error when deploying API Gateway: A GET request to ... - GitHub
When I ran zappa deploy and now when I run zappa update, it seems to go okay - it downloads and installs dependencies,...
Read more >Zappa deploy error deployed lambda failed. A GET request to ...
when I run zappa deploy dev it returns 502 response error ERROR showing : Error: Warning! Status check on the deployed lambda failed....
Read more >New for AWS Lambda – Container Image Support - Noise
The Lambda Runtime Interface Emulator is included in all AWS-provided base images and can be used with arbitrary images as well.
Read more >Serverless Docker on AWS Lambda with Zappa - Ian Whitestone
I've been using Zappa to manage my serverless Python deployments for over a year now. Zappa is magic. If you've ever tried to...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Good to know!
For anyone browsing this thread looking for ideas about the 504 error - in my case, my app.py script was importing a ton of heavy libraries. Just importing the libraries and instantiating a few global objects was taking ~60s, by which time a timeout error was thrown. Moving the imports and instantiations to the route instead of keeping them global, and also using the
task
async decorator solved the issue for me.Update for anyone facing similar issues: FIXED
I try/except’ed every import statement in my app and printed out all failures. Turns out all my issues were caused because of module import errors. After resolving those import paths, my app loads successfully. Not sure why this had to be done since Dockerizing the app shouldn’t have allowed import errors to exist (or am I mistaken?).
I’m now facing 504 timeout errors, but that’s a story for another day.