alhazmy13 / serverless-offline-python

Emulate AWS λ and API Gateway locally when developing your Serverless project
MIT License
35 stars 18 forks source link

AWS.invoke does not work, but it works with serverless-offline pkg #12

Open clapas opened 5 years ago

clapas commented 5 years ago

Using "serverless-offline-python": "^3.22.1" -> Does not work as explained in https://www.npmjs.com/package/serverless-offline#usage-with-invoke

Using "serverless-offline": "^5.10.1" -> Does work.

CountZachula commented 5 years ago

I am experiencing the same problem. Calling Invoke with any configuration seems to yield a 404. Switching from "serverless-offline-python" to "serverless-offline" resolves the issue.

Although this sample code may not work entirely, I'm merely demonstrating the invoke portion.

# handler.py

import json
import boto3

client = boto3.client(
    'lambda',
    endpoint_url='http://localhost:3000',
    region_name='eu-central-1',
    use_ssl=False
)

def other(event, context):
    response = {
        "statusCode": 200,
        "body": json.dumps({})
    }
    return response

def hello(event, context):
    response = client.invoke(
        FunctionName='hello-dev-other',
        InvocationType='RequestResponse',
        Payload=json.dumps({})
    )
    return response
# serverless.yml

service: hello
provider:
  name: aws
  runtime: python3.6
  region: eu-central-1

plugins:
  # - serverless-offline
  - serverless-offline-python

functions:
  hello:
    handler: handler.hello
    events:
      - http:
          path: "/hello"
          method: get
  other:
    handler: handler.other