0

Here is my serverless.yml file:

service: investor-bot


provider:
  name: aws
  runtime: python3.9
  stage: dev


functions:
  post:
    handler: handler.hello
    events:
      - http:
          path: ita-investor-bot
          method: get

Here is code (even with this code it does not work):

def hello(event, context):
    return {"statusCode": 200}

I exported my AWS credentials and ran serverless deploy:

Serverless: Packaging service...
Serverless: Excluding development dependencies...
Serverless: Uploading CloudFormation file to S3...
Serverless: Uploading artifacts...
Serverless: Uploading service investor-bot.zip file to S3 (12.77 MB)...
Serverless: Validating template...
Serverless: Updating Stack...
Serverless: Checking Stack update progress...
.......................................
Serverless: Stack update finished...
Service Information
service: investor-bot
stage: dev
region: us-east-1
stack: investor-bot-dev
resources: 11
api keys:
  None
endpoints:
  GET - https://933zcto8tc.execute-api.us-east-1.amazonaws.com/dev/ita-investor-bot
functions:
  post: investor-bot-dev-post
layers:
  None
Serverless: Removing old service artifacts from S3...
Serverless: Deprecation warning: Resolution of lambda version hashes was improved with better algorithm, which will be used in next major release.
            Switch to it now by setting "provider.lambdaHashingVersion" to "20201221"
            More Info: https://www.serverless.com/framework/docs/deprecations/#LAMBDA_HASHING_VERSION_V2

Toggle on monitoring with the Serverless Dashboard: run "serverless"

I see nothing at the AWS account in API Gateway. I can not access endpoint: enter image description here

5
  • There is an endpoint, it's just that the code therein is throwing an unhandled error, so API gateway returns 500; if there was no endpoint, it would 404. Commented Oct 28, 2021 at 16:18
  • To debug your code, look in the AWS console for he specific errors being thrown: console.aws.amazon.com/cloudwatch/home... or you can also tail the logs from your CLI: serverless logs -f <functionName> -t Commented Oct 28, 2021 at 16:19
  • Also, try including "body": "" in your return...? serverless.com/framework/docs/providers/aws/examples/… Commented Oct 28, 2021 at 16:22
  • @AdamSmooch No, there is nothing in logs and in cloudwatch. I mentioned, that at API Gateway page api does not appear, there is literally nothing. Commented Oct 28, 2021 at 17:07
  • and when you login here? aws.amazon.com/api-gateway. Post screenshots of Cloudwatch + API-gateway UIs Commented Oct 28, 2021 at 18:41

2 Answers 2

1

There's definitely a deployed API Gateway. You've deployed your stack in us-east-1, my best guess is that you're using the AWS console in another region.

When logged in to the AWS console, use the region switcher on the top-right to switch to us-east-1, from there you should see your API Gateway, lambda function, and cloudwatch logs.

Sign up to request clarification or add additional context in comments.

Comments

0

If anyone is finding this question in 2023, I encountered this problem as well and found that the API gateway is not created if you only define the function (just define the handler). The API gateway will be created when you add the keys events -> http -> path + method to your function definition.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.