in src/stepfunctions/workflow/stepfunctions.py [0:0]
def update(self, definition=None, role=None):
"""
Updates an existing state machine by modifying its definition and/or role. Executions started immediately after calling this method may use the previous definition and role.
Args:
definition (State or Chain, optional): The `Amazon States Language <https://states-language.net/spec.html>`_ definition to update the workflow with. (default: None)
role (str, optional): The Amazon Resource Name (ARN) of the IAM role to use for creating, managing, and running the workflow. (default: None)
Returns:
str: The state machine definition and/or role updated. If the update fails, None will be returned.
"""
if definition is None and role is None:
raise MissingRequiredParameter("A new definition and/or role must be provided to update an existing workflow.")
if self.state_machine_arn is None:
raise WorkflowNotFound("Local workflow instance does not point to an existing workflow on AWS StepFunctions. Please consider using Workflow.create(...) to create a new workflow, or Workflow.attach(...) to attach the instance to an existing workflow on AWS Step Functions.")
if definition:
if isinstance(definition, Graph):
self.definition = definition
else:
self.definition = Graph(
definition,
timeout_seconds=self.timeout_seconds,
comment=self.comment,
version=self.version
)
if role:
self.role = role
response = self.client.update_state_machine(
stateMachineArn=self.state_machine_arn,
definition=self.definition.to_json(pretty=self.format_json),
roleArn=self.role
)
logger.info("Workflow updated successfully on AWS Step Functions. All execute() calls will use the updated definition and role within a few seconds. ")
return self.state_machine_arn