The Amazon SDK for JavaScript V3 API
Reference Guide
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 Amazon 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 and cross-service examples.
Scenarios are code examples that show you how to accomplish a specific task by calling multiple functions within the same service.
Each example includes a link to GitHub, 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 Amazon Code Examples Repository
. // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. // SPDX-License-Identifier: Apache-2.0 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 "url"; if (process.argv[1] === fileURLToPath(import.meta.url)) { startExecution({ sfnClient: new SFNClient({}), stateMachineArn: "ARN" }); }
-
For API details, see StartExecution in Amazon SDK for JavaScript API Reference.
-