def attach()

in src/stepfunctions/workflow/stepfunctions.py [0:0]


    def attach(cls, state_machine_arn, client=None):
        """
        Factory method to create an instance attached to an exisiting workflow in Step Functions.

        Arguments:
            state_machine_arn (str): The Amazon Resource Name (ARN) of the existing workflow.
            client (SFN.Client, optional): boto3 client to use for attaching the existing workflow in Step Functions to the Workflow object.
                                           If not provided, a default boto3 client for Step Functions will be automatically created and used. (default: None)

        Returns:
            Workflow: Workflow object attached to the existing workflow in Step Functions.
        """
        if client is None:
            logger.debug("The argument 'client' is not provided. Creating a new boto3 client instance with default settings.")
            client = boto3.client('stepfunctions')

        response = client.describe_state_machine(stateMachineArn=state_machine_arn)
        return Workflow(
            name=response['name'],
            definition=FrozenGraph.from_json(response['definition']),
            role=response['roleArn'],
            state_machine_arn=response['stateMachineArn'],
            client=client
        )