Skip to content
Advertisement

Is it possible to call AWS Step Functions from AWS JavaScript v3 SDK?

I posted this question on the forums back in August requesting when the V3 JavaScript API would add support to AWS Step Functions as it is in the V2 SDK. I haven’t heard anything on that thread.

Is there an alternate solution that someone has which I can migrate away from the V2 SDK?

Advertisement

Answer

Currently there is support for invoking Step Functions from AWS V3 Javascript sdk.

For standard invocation we can use StartExecutionCommand, or we can use StartSyncExecutionCommand for Synchronous Express step functions.

Here is an example for a standard invocation using Node.js:

const { SFNClient, StartExecutionCommand } = require("@aws-sdk/client-sfn");

const client = new SFNClient({ region: 'us-east-1' });

async function invoke(executionName, arn, input) {
    const command = new StartExecutionCommand({
        input: JSON.stringify(input),
        name: executionName,
        stateMachineArn: arn
    });
    return await client.send(command);
}

(async () => {
    console.log(await invoke('execution123', '' +
        'arn:aws:states:us-east-1:XXXXXXXXX:stateMachine:HelloWorld',
        {fistName: 'test'}));
})();
User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement