Aws-sam-cli: hello_world example not working

Created on 31 Aug 2018  路  3Comments  路  Source: aws/aws-sam-cli

Description:

I have created the hello_world example from https://github.com/awslabs/aws-sam-cli/blob/develop/docs/getting_started.rst and followed the steps from README.md to build and execute a local server.

But when acessing the server from http://127.0.0.1:3001/hello (also tried http://127.0.0.1:3001) I get the following response:

{"Type": "LocalService", "Message": "PathNotFoundException"}

Steps to reproduce the issue:

  1. Install Miniconda Python 3.6
  2. <miniconda_bin_dir>/pip install aws-sam-cli
  3. <miniconda_bin_dir>/sam init --runtime python3.6
  4. cd sam-app
  5. <miniconda_bin_dir>/pip install -r requirements.txt -t hello_world/build/
  6. cp hello_world/*.py hello_world/build/
  7. <miniconda_bin_dir>/sam --debug local start-lambda

Observed result:

The following response from http://127.0.0.1:3001/hello:

{"Type": "LocalService", "Message": "PathNotFoundException"}

Expected result:

The actual output from app.py

Additional environment details (Ex: Windows, Mac, Amazon Linux etc)

Linux Mint 18
Docker version 18.06.0-ce, build 0ffa825
Miniconda Python 3.6.5

Output of sam --version:

SAM CLI, version 0.6.0

Optional Debug logs:

$ sam --debug local start-lambda
2018-08-30 23:19:57 local start_lambda command is called
2018-08-30 23:19:57 2 resources found in the template
2018-08-30 23:19:57 Found Serverless function with name='HelloWorldFunction' and CodeUri='hello_world/build/'
2018-08-30 23:19:57 Trying paths: ['/home/caian/.docker/config.json', '/home/caian/.dockercfg']
2018-08-30 23:19:57 No config file found
2018-08-30 23:19:57 Trying paths: ['/home/caian/.docker/config.json', '/home/caian/.dockercfg']
2018-08-30 23:19:57 No config file found
2018-08-30 23:19:57 http://localhost:None "GET /v1.35/_ping HTTP/1.1" 200 2
2018-08-30 23:19:57 Trying paths: ['/home/caian/.docker/config.json', '/home/caian/.dockercfg']
2018-08-30 23:19:57 No config file found
2018-08-30 23:19:57 Trying paths: ['/home/caian/.docker/config.json', '/home/caian/.dockercfg']
2018-08-30 23:19:57 No config file found
2018-08-30 23:19:57 Starting the Local Lambda Service. You can now invoke your Lambda Functions defined in your template through the endpoint.
2018-08-30 23:19:57 Localhost server is starting up. Multi-threading = True
2018-08-30 23:19:57  * Running on http://127.0.0.1:3001/ (Press CTRL+C to quit)
2018-08-30 23:23:28 127.0.0.1 - - [30/Aug/2018 23:23:28] "GET /hello HTTP/1.1" 404 -
2018-08-30 23:23:33 127.0.0.1 - - [30/Aug/2018 23:23:33] "GET / HTTP/1.1" 404 -

Most helpful comment

@Caian You are running the wrong command. The README for sam init states to run sam local start-api.

sam local start-lambda runs a localhost service that mimics the invoke path on the Lambda service locally, so you can invoke the functions locally through AWS CLI or AWS SDKs.

Closing as this is not an issue and the wrong command was run.

All 3 comments

@Caian You are running the wrong command. The README for sam init states to run sam local start-api.

sam local start-lambda runs a localhost service that mimics the invoke path on the Lambda service locally, so you can invoke the functions locally through AWS CLI or AWS SDKs.

Closing as this is not an issue and the wrong command was run.

That's really embarrassing, sorry!

So I ran sam local start-lambda and now it is working!

Thank you

It could be a little clearer though. No where in the Creating a hello-world app, does it mention how to run the lambda, yes it does if you follow the...

[SUCCESS] - Read sam-app/README.md for further instructions on how to proceed

but, I think many people will just be working through the main Usage docs, everyone gets their eventually, but it could be a little more obvious.

Everything is obvious in hind-sight.

Was this page helpful?
0 / 5 - 0 ratings