serverless-offline-python icon indicating copy to clipboard operation
serverless-offline-python copied to clipboard

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

Open clapas opened this issue 6 years ago • 1 comments

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.

clapas avatar Aug 08 '19 16:08 clapas

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

CountZachula avatar Aug 09 '19 17:08 CountZachula