aws / aws/aws-lambda-base-images
Can't invoke Python 3.7 image locally
- Dominant language
- No language data
- Stars
- 777
- Forks
- 118
- PR merge metrics
- No merged PRs in 30d
Description
I'm trying to deploy a function and am having issues testing locally (on a linux server) as described in the docs:
https://docs.aws.amazon.com/lambda/latest/dg/images-test.html#images-test-AWSbase
https://hub.docker.com/r/amazon/aws-lambda-python
Here are the steps to reproduce, using a simple Python app:
1. Create app.py:
```python
def main(event, context):
print(event)
print()
print(context)
if __name__ == '__main__':
event = 'testing'
context = '123'
main(event, context)
```
2. Create Dockerfile:
```dockerfile
FROM amazon/aws-lambda-python:3.7
COPY app.py ${LAMBDA_TASK_ROOT}
CMD ["app.main"]
```
3. Build container:
```shell
docker build -t local-lambda-test .
```
4. Start the container in one shell:
```shell
docker run -p 9000:8080 local-lambda-test:latest
```
5. In another shell, send the container the same test payload from the docs:
```shell
curl -XPOST "http://localhost:9000/2015-03-31/functions/function/invocations" -d '{"payload":"hello world!"}'
```
I expect to see the container logs print the payload and context, but instead I get a bad response and the container does nothing.
----
Here is what happens on my end after I start the container as in step 4 above:
1. I run `docker run -p 9000:8080 local-lambda-test:latest` and get the following output:

2. Verify connection with telnet to rule out connection issues:

3. Send payload to the container and get an error in the response:

---
For the love of all that is holy, does anyone know what's going on here?! Have any of you seen this problem before, or have an idea of where I might be going wrong?
Thanks!
Contributor guide
Assessment
This issue has not been assessed yet.