How can i call "sendTaskSuccess" that return the token to a waiting state in stepfunction. not using lambda function

Viewed 838

I have an external service which is called by a state in aws step function, now from this external service i want to send "sendTaskSuccess" to the particular aws step machine. How can i do that. I know that we can call "sendSuccessToken" from lambda but want to know how to use "sendSuccessToken" without lambda.

1 Answers

The state machine ARN is not used .The step in the state machine that await a callback have a taskToken which uniquely identifies a specific task and a specific execution of state machine.

The ideal way to do this would be : Step 1: Store the taskToken in a persistent storage before invoking the external service

export const lambdaHandler: ProxyHandler = async (event, context) => {

    const evt = JSON.parse(JSON.stringify(event));
    const taskToken = evt['token'];
    
    const dbObject = 
    {
        SomeHelpfulInfo: 'set a suitable identifier',
        taskToken:taskToken
    };
    StoreTaskToken(dbObject);
    //call external service as per your logic
//

}

Step 2: Read the taskToken from the persistent storage and invoke the step function task success

import { StepFunctions } from 'aws-sdk';

const stepfunctions = new StepFunctions();

const taskToken = GetTaskTokenFromDb(); //Have your implementation to get taskToken

const params = {
            output: '',
            taskToken: taskToken
        };
        
let result = await stepfunctions.sendTaskSuccess(params).promise();
console.log('State machine - callback completed..');
Related