startWorkflowRun method

Future<StartWorkflowRunResponse> startWorkflowRun({
  1. required String workflowArn,
  2. String? clientToken,
  3. Map<String, Document>? overrideParameters,
  4. String? workflowVersion,
})

Starts a new execution of a workflow. This operation creates a workflow run that executes the tasks that are defined in the workflow. Amazon Managed Workflows for Apache Airflow Serverless schedules the workflow execution across its managed Airflow environment, automatically scaling ECS worker tasks based on the workload. The service handles task isolation, dependency resolution, and provides comprehensive monitoring and logging throughout the execution lifecycle.

May throw AccessDeniedException. May throw ConflictException. May throw InternalServerException. May throw OperationTimeoutException. May throw ResourceNotFoundException. May throw ServiceQuotaExceededException. May throw ThrottlingException. May throw ValidationException.

Parameter workflowArn : The Amazon Resource Name (ARN) of the workflow you want to run.

Parameter clientToken : A unique, case-sensitive identifier that you provide to ensure the idempotency of the request. This token prevents duplicate workflow run requests.

Parameter overrideParameters : Optional parameters to override default workflow parameters for this specific run. These parameters are passed to the workflow during execution and can be used to customize behavior without modifying the workflow definition. Parameters are made available as environment variables to tasks and you can reference them within the YAML workflow definition using standard parameter substitution syntax.

Parameter workflowVersion : Optional. The specific version of the workflow to execute. If not specified, the latest version is used.

Implementation

Future<StartWorkflowRunResponse> startWorkflowRun({
  required String workflowArn,
  String? clientToken,
  Map<String, Document>? overrideParameters,
  String? workflowVersion,
}) async {
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.0',
    'X-Amz-Target': 'AmazonMWAAServerless.StartWorkflowRun'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'WorkflowArn': workflowArn,
      'ClientToken': clientToken ?? _s.generateIdempotencyToken(),
      if (overrideParameters != null)
        'OverrideParameters': overrideParameters,
      if (workflowVersion != null) 'WorkflowVersion': workflowVersion,
    },
  );

  return StartWorkflowRunResponse.fromJson(jsonResponse.body);
}