createWorkflow method

Future<CreateWorkflowResponse> createWorkflow({
  1. required DefinitionS3Location definitionS3Location,
  2. required String name,
  3. required String roleArn,
  4. String? clientToken,
  5. String? description,
  6. EncryptionConfiguration? encryptionConfiguration,
  7. int? engineVersion,
  8. LoggingConfiguration? loggingConfiguration,
  9. NetworkConfiguration? networkConfiguration,
  10. Map<String, String>? tags,
  11. String? triggerMode,
})

Creates a new workflow in Amazon Managed Workflows for Apache Airflow Serverless. This operation initializes a workflow with the specified configuration including the workflow definition, execution role, and optional settings for encryption, logging, and networking. You must provide the workflow definition as a YAML file stored in Amazon S3 that defines the DAG structure using supported Amazon Web Services operators. Amazon Managed Workflows for Apache Airflow Serverless automatically creates the first version of the workflow and sets up the necessary execution environment with multi-tenant isolation and security controls.

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

Parameter definitionS3Location : The Amazon S3 location where the workflow definition file is stored. This must point to a valid YAML file that defines the workflow structure using supported Amazon Web Services operators and tasks. Amazon Managed Workflows for Apache Airflow Serverless takes a snapshot of the definition at creation time, so subsequent changes to the Amazon S3 object will not affect the workflow unless you create a new version. In your YAML definition, include task dependencies, scheduling information, and operator configurations that are compatible with the Amazon Managed Workflows for Apache Airflow Serverless execution environment.

Parameter name : The name of the workflow. You must use unique workflow names within your Amazon Web Services account. The service generates a unique identifier that is appended to ensure temporal uniqueness across the account lifecycle.

Parameter roleArn : The Amazon Resource Name (ARN) of the IAM role that Amazon Managed Workflows for Apache Airflow Serverless assumes when executing the workflow. This role must have the necessary permissions to access the required Amazon Web Services services and resources that your workflow tasks will interact with. The role is used for task execution in the isolated, multi-tenant environment and should follow the principle of least privilege. Amazon Managed Workflows for Apache Airflow Serverless validates role access during workflow creation but runtime permission checks are performed by the target services.

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

Parameter description : An optional description of the workflow that you can use to provide additional context about the workflow's purpose and functionality.

Parameter encryptionConfiguration : The configuration for encrypting workflow data at rest and in transit. Specifies the encryption type and optional KMS key for customer-managed encryption.

Parameter engineVersion : The version of the Amazon Managed Workflows for Apache Airflow Serverless engine that you want to use for this workflow. This determines the feature set, supported operators, and execution environment capabilities available to your workflow. Amazon Managed Workflows for Apache Airflow Serverless maintains backward compatibility across versions while introducing new features and improvements. Currently supports version 1 with plans for additional versions as the service evolves.

Parameter loggingConfiguration : The configuration for workflow logging. Specifies the CloudWatch log group where workflow execution logs are stored. Amazon Managed Workflows for Apache Airflow Serverless automatically exports worker logs and task-level information to the specified log group in your account using remote logging functionality. This provides comprehensive observability for debugging and monitoring workflow execution across the distributed, serverless environment.

Parameter networkConfiguration : Network configuration for the workflow execution environment, including VPC security groups and subnets for secure network access. When specified, Amazon Managed Workflows for Apache Airflow Serverless deploys ECS worker tasks in your customer VPC to provide secure connectivity to your resources. If not specified, tasks run in the service's default worker VPC with network isolation from other customers. This configuration enables secure access to VPC-only resources like RDS databases or private endpoints.

Parameter tags : A map of tags to assign to the workflow resource. Tags are key-value pairs that are used for resource organization and cost allocation.

Parameter triggerMode : The trigger mode for the workflow execution.

Implementation

Future<CreateWorkflowResponse> createWorkflow({
  required DefinitionS3Location definitionS3Location,
  required String name,
  required String roleArn,
  String? clientToken,
  String? description,
  EncryptionConfiguration? encryptionConfiguration,
  int? engineVersion,
  LoggingConfiguration? loggingConfiguration,
  NetworkConfiguration? networkConfiguration,
  Map<String, String>? tags,
  String? triggerMode,
}) async {
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.0',
    'X-Amz-Target': 'AmazonMWAAServerless.CreateWorkflow'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'DefinitionS3Location': definitionS3Location,
      'Name': name,
      'RoleArn': roleArn,
      'ClientToken': clientToken ?? _s.generateIdempotencyToken(),
      if (description != null) 'Description': description,
      if (encryptionConfiguration != null)
        'EncryptionConfiguration': encryptionConfiguration,
      if (engineVersion != null) 'EngineVersion': engineVersion,
      if (loggingConfiguration != null)
        'LoggingConfiguration': loggingConfiguration,
      if (networkConfiguration != null)
        'NetworkConfiguration': networkConfiguration,
      if (tags != null) 'Tags': tags,
      if (triggerMode != null) 'TriggerMode': triggerMode,
    },
  );

  return CreateWorkflowResponse.fromJson(jsonResponse.body);
}