There are more AWS SDK examples available in the AWS Doc SDK Examples
Step Functions examples using SDK for JavaScript (v3)
The following code examples show you how to perform actions and implement common scenarios by using the AWS SDK for JavaScript (v3) with Step Functions.
Actions are code excerpts from larger programs and must be run in context. While actions show you how to call individual service functions, you can see actions in context in their related scenarios.
Each example includes a link to the complete source code, where you can find instructions on how to set up and run the code in context.
Topics
Actions
The following code example shows how to use StartExecution
.
- SDK for JavaScript (v3)
-
Note
There's more on GitHub. Find the complete example and learn how to set up and run in the AWS Code Examples Repository
. import { SFNClient, StartExecutionCommand } from "@aws-sdk/client-sfn"; /** * @param {{ sfnClient: SFNClient, stateMachineArn: string }} config */ export async function startExecution({ sfnClient, stateMachineArn }) { const response = await sfnClient.send( new StartExecutionCommand({ stateMachineArn, }), ); console.log(response); // Example response: // { // '$metadata': { // httpStatusCode: 200, // requestId: '202a9309-c16a-454b-adeb-c4d19afe3bf2', // extendedRequestId: undefined, // cfId: undefined, // attempts: 1, // totalRetryDelay: 0 // }, // executionArn: 'arn:aws:states:us-east-1:000000000000:execution:MyStateMachine:aaaaaaaa-f787-49fb-a20c-1b61c64eafe6', // startDate: 2024-01-04T15:54:08.362Z // } return response; } // Call function if run directly import { fileURLToPath } from "node:url"; if (process.argv[1] === fileURLToPath(import.meta.url)) { startExecution({ sfnClient: new SFNClient({}), stateMachineArn: "ARN" }); }
-
For API details, see StartExecution in AWS SDK for JavaScript API Reference.
-