So I took the Hello World Step function example and wanted a Lambda to trigger the execution
My Lambda code is as below:
The code invokes a Step Function. We need the Step function ARN
The startExecution method is blocking and returns (in success) an executionArn, that can be used to find the execution in AWS console. The describeExecution method helps identify the status of the execution. A response of "SUCCEEDED" indicates that the step function succeeded. I ran the lambda through the test button on AWS:
The step by step execution was
I also wanted to pass some inputs to my step function from Lambda. The new version of Hello World takes an input:
The only change to my Lambda was to change the Step Function StartExecutionRequest to add input:
My Lambda code is as below:
1 | publicclassStepFnExecutorLambdaimplements RequestHandler<String, Boolean>{ +", "+ context.getFunctionVersion()); awsStepFunctionsClient.startExecution(startExecutionRequest); new DescribeExecutionRequest(); awsStepFunctionsClient.describeExecution(describeExecutionRequest); |
Amazon Resource Names (ARNs) uniquely identify AWS resources. We require an ARN when you need to specify a resource unambiguously across all of AWS, such as in IAM policies, Amazon Relational Database Service (Amazon RDS) tags, and API calls. |
START RequestId: 58652a12-181e-48f9-a951-208d4abbbb83 Version: $LATESTLooking at the execution ARN on Step functions Console
In Handler: Executing testStepFn, $LATEST
key1
Execution started with arn arn:aws:states:us-east-1:360767005075:execution:TestStateMachine:4ad95d88-0064-4079-87b8-1252d7a09b7d
Execution with arn arn:aws:states:us-east-1:360767005075:execution:TestStateMachine:4ad95d88-0064-4079-87b8-1252d7a09b7d returned status RUNNING
Execution with arn arn:aws:states:us-east-1:360767005075:execution:TestStateMachine:4ad95d88-0064-4079-87b8-1252d7a09b7d returned status SUCCEEDED
Final Status arn:aws:states:us-east-1:360767005075:execution:TestStateMachine:4ad95d88-0064-4079-87b8-1252d7a09b7d : SUCCEEDED
END RequestId: 58652a12-181e-48f9-a951-208d4abbbb83
REPORT RequestId: 58652a12-181e-48f9-a951-208d4abbbb83 Duration: 4118.52 ms Billed Duration: 4200 ms Memory Size: 512 MB
Max Memory Used: 125 MB Init Duration: 1573.71 ms
The step by step execution was
I also wanted to pass some inputs to my step function from Lambda. The new version of Hello World takes an input:
The only change to my Lambda was to change the Step Function StartExecutionRequest to add input:
StartExecutionRequest startExecutionRequest = new StartExecutionRequest();This code ran cleanly on execution:
startExecutionRequest.setStateMachineArn("arn:aws:states:us-east-1:466170491455:stateMachine:TestStateMachine");
startExecutionRequest.setInput("{\"IsHelloWorldExample\": true}");
START RequestId: 47c62fe2-8fdd-4fc1-8185-00b388519109 Version: $LATEST
In Handler: Executing InvokeStepFn, $LATEST
Help
Execution started with arn arn:aws:states:us-east-1:466170491455:execution:TestStateMachine:STEP_FN_REQ_ID
Execution with arn arn:aws:states:us-east-1:466170491455:execution:TestStateMachine:STEP_FN_REQ_ID
returned status RUNNING
...
Execution with arn arn:aws:states:us-east-1:466170491455:execution:TestStateMachine:STEP_FN_REQ_ID
returned status SUCCEEDED
Final Status arn:aws:states:us-east-1:466170491455:execution:TestStateMachine:STEP_FN_REQ_ID : SUCCEEDED
END RequestId: 47c62fe2-8fdd-4fc1-8185-00b388519109
REPORT RequestId: 47c62fe2-8fdd-4fc1-8185-00b388519109 Duration: 7517.94 ms
Billed Duration: 7600 ms Memory Size: 512 MB Max Memory Used: 126 MB Init Duration: 1557.02 ms


