Skip to content

Latest commit

 

History

History
96 lines (82 loc) · 3.72 KB

File metadata and controls

96 lines (82 loc) · 3.72 KB

Step Functions with API Gateway

step-function-with-api-gateway

Invoking the Step Function using the API Gateway. Configuring the API Gateway Integration settings, for AWS Service it must be Step Function, for Action Type, you must use the Use action name and enter the StartSyncExecution for Action.

State Machine Definition

{
  "StartAt": "Pass",
  "States": {
    "Pass": {
      "Type": "Pass",
      "End": true
    }
  }
}

Sample Payload

{
  "input": "{}",
  "name": "MyExecution"
}

Sample API Gateway Response

{
  "billingDetails": {
    "billedDurationInMilliseconds": 100,
    "billedMemoryUsedInMB": 64
  },
  "executionArn": "arn:aws:states:us-east-1:123456789101:express:sf-state-machine:1fe234a5-d61a-7891-0cdf-11121d3141b5:1efa2345-b678-9101-1ade-12f1ed314ccc",
  "input": "{\"input\":\"{}\",\"name\":\"MyExecution\"}",
  "inputDetails": {
    "__type": "com.amazonaws.swf.base.model#CloudWatchEventsExecutionDataDetails",
    "included": true
  },
  "name": "1fe234a5-d61a-7891-0cdf-11121d3141b5",
  "output": "{\"input\":\"{}\",\"name\":\"MyExecution\"}",
  "outputDetails": {
    "__type": "com.amazonaws.swf.base.model#CloudWatchEventsExecutionDataDetails",
    "included": true
  },
  "startDate": 1.683799126827E9,
  "stateMachineArn": "arn:aws:states:us-east-1:123456789101:stateMachine:sf-state-machine",
  "status": "SUCCEEDED",
  "stopDate": 1.683799126837E9,
  "traceHeader": "Root=1-234cbc56-78eecf9101bc112f131e41a5;Parent=12d345678d9d10dd;Sampled=1"
}

AWS CDK API / Developer Reference

AWS Documentation Developer Guide

Useful commands

  • npm run build compile typescript to js
  • npm run watch watch for changes and compile
  • npm run test perform the jest unit tests
  • cdk deploy deploy this stack to your default AWS account/region
  • cdk diff compare deployed stack with current state
  • cdk synth emits the synthesized CloudFormation template

Deploy

Using make command

  1. Install all the dependencies, bootstrap your project, and synthesized CloudFormation template.

    # Without passing "profile" parameter
    dev@dev:~:aws-cdk-samples/step-functions/step-functions-api-gateway$ make init
    
    # With "profile" parameter
    dev@dev:~:aws-cdk-samples/step-functions/step-functions-api-gateway$ make init profile=[profile_name]
  2. Deploy the project.

    # Without passing "profile" parameter
    dev@dev:~:aws-cdk-samples/step-functions/step-functions-api-gateway$ make deploy
    
    # With "profile" parameter
    dev@dev:~:aws-cdk-samples/step-functions/step-functions-api-gateway$ make deploy profile=[profile_name]