'How can I specify method and path for calling lambda function from step function?

I'd like to call lambda function using a state machine with passing path and method (as in usual HTTP sense). Current serverless template to achieve that is the following:

functions:
  myfunction:
    handler: bin/myfunction
    events:
      - http:
          path: setup
          method: POST

stepFunctions:
  validate: true
  stateMachines:
    myMachine:
      name: myMachine
      definition:
        StartAt: Setup
        States:
          Setup:
            Type: Task
            Resource:
              Fn::GetAtt: [myfunction, Arn]
            Parameters:
              InvocationType: Event
              Payload:
                path: "/setup"
                httpMethod: "POST"
                body: ""
            End: true

However, the actual call that arrives to myfunction is a GET request with path /. Fields that I used as a payload are from lambda:InvokeFunction API where one can set body, path and httpMethod as a json in Payload property of lambda.InvokeInput and get everything called correctly.

How to replicate the same with my example?



Solution 1:[1]

path and httpMethod are for invoking an API Gateway route, not a Lambda function.

A Lambda function invocation (mostly) takes a function name, invocation type & a payload.

If you must go via API Gateway, take a look at the official 'Call API Gateway with Step Functions' guide on how to do this otherwise just invoke your Lambda manually.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Ermiya Eskandary