AWS API Gateway with Step Function

前端 未结 3 1888
刺人心
刺人心 2021-01-02 21:13

I want a sample to integrate AWS API Gateway with Step Function. I have read this tutorial Creating a Step Functions API Using API Gateway but that tutorial needs me to send

3条回答
  •  别那么骄傲
    2021-01-02 21:51

    Create your API Gateway resource and method. Then in the "Method Execution" settings, in the Integration Request, use these settings:

    • Integration type: AWS Service
    • AWS Region: your region
    • AWS Service: Step Functions
    • AWS Subdomain: your subdomain if you have one - I left it blank
    • HTTP method: POST
    • Action: StartExecution
    • Execution role: needs to be a role with StepFunction start execute policy, such as arn:aws:iam::aws:policy/AWSStepFunctionsFullAccess
    • Credentials cache: I left this as default
    • Content Handling: Passthrough

    Then the magic. Futher down, under Body Mapping Templates:

    • Request body passthrough: Never
    • Add mapping template : application/json

    Futher down in the template text box:

    #set($input = $input.json('$'))
    {
       "input": "$util.escapeJavaScript($input)",
       "stateMachineArn": "arn:aws:states:eu-west-1:123456789012:stateMachine:yourStepFunctionName"
    }
    

    This will pass the json payload posted to API Gateway through to the Step Function.

    Omit the execution name so that each call to API Gateway creates a new execution.

提交回复
热议问题