Skip to content

Activity

Source: src/AWS/StepFunctions/Activity.ts

An AWS Step Functions activity — a named endpoint that external workers poll for tasks (GetActivityTask) and complete with the SendTask* callback operations.

Activities support worker-hosted task processing outside Lambda. For most callback flows the .waitForTaskToken service-integration pattern on a StateMachine Task state is preferred.

Basic Activity

import * as StepFunctions from "alchemy/AWS/StepFunctions";
const activity = yield* StepFunctions.Activity("ApprovalActivity");

Reference an Activity from a State Machine

const machine = yield* StepFunctions.StateMachine("ApprovalFlow", {
definition: {
StartAt: "WaitForWorker",
States: {
WaitForWorker: {
Type: "Task",
Resource: activity.activityArn,
End: true,
},
},
},
});
// init
const sendTaskSuccess = yield* StepFunctions.SendTaskSuccess(activity);
// runtime
yield* sendTaskSuccess({
taskToken: token,
output: JSON.stringify({ approved: true }),
});