
Activities are a Step Functions feature that enables you to process messages in an external worker running in Amazon EKS task, on-premise servers etc. As activities act as queue between the Step Functions workflow and the external system, they offer a highly scalable, resilient and asynchronous mechanism to connect your services running in Amazon ECS tasks, Amazon EKS pods or basically anywhere. You can use Step Functions activity metrics such as ActivitiesScheduled and ActivitiesStarted to scale in/scale out the workers.
To get started with activities, you create an activity in Step Functions console, API, CLI or in a workflow. You then use the activity state in the workflow to send the task to the activities. The data waits in the activity until it is consumed by the worker. Here is a sample code for worker to consume task from Step Functions activity.
client = boto3.client('stepfunctions', region_name=region, config=config)
activity = client.get_activity_task(
activityArn = activity_arn,
workerName = worker_name
)
Worker receives tasktoken and the task input. Once the worker completes the processing, it sends the success or failure back to Step Functions. This mechanism works very similar to Wait for a Callback integration.

if success:
client.send_task_success(
taskToken = activity['taskToken'],
output = stringoutput
)
else:
client.send_task_failure(
taskToken = activity['taskToken'],
cause = strCause,
error = strError
)
Advantages of Activity integration