Skip to content

create_workflow

create_workflow(
    name: NameString,
    definition_s3_location: DefinitionS3Location,
    role_arn: RoleARN,
    *,
    config_overrides: Optional[MWAAServerlessClientConfig] = None,
    client_token: Optional[IdempotencyTokenString] = None,
    code: Optional[Code] = None,
    description: Optional[DescriptionString] = None,
    encryption_configuration: Optional[EncryptionConfiguration] = None,
    logging_configuration: Optional[LoggingConfiguration] = None,
    engine_version: Optional[EngineVersion] = None,
    network_configuration: Optional[NetworkConfiguration] = None,
    tags: Optional[Tags] = None,
    trigger_mode: Optional[GenericString] = None,
) -> CreateWorkflowResponse

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.

Parameters:

  • name (NameString) –

    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.

  • client_token (Optional[IdempotencyTokenString], default: None ) –

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

  • definition_s3_location (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.

  • code (Optional[Code], default: None ) –

    The location of code artifacts in Amazon S3 for the workflow. The service copies the code from this location at the time of the request.

  • role_arn (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.

  • description (Optional[DescriptionString], default: None ) –

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

  • encryption_configuration (Optional[EncryptionConfiguration], default: None ) –

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

  • logging_configuration (Optional[LoggingConfiguration], default: None ) –

    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.

  • engine_version (Optional[EngineVersion], default: None ) –

    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.

  • network_configuration (Optional[NetworkConfiguration], default: None ) –

    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.

  • tags (Optional[Tags], default: None ) –

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

  • trigger_mode (Optional[GenericString], default: None ) –

    The trigger mode for the workflow execution.

Raises:

  • AccessDeniedException –

    You do not have sufficient permission to perform this action.

  • ConflictException –

    You cannot create a resource that already exists, or the resource is in a state that prevents the requested operation.

  • InternalServerException –

    An unexpected server-side error occurred during request processing.

  • OperationTimeoutException –

    The operation timed out.

  • ServiceQuotaExceededException –

    The request exceeds the service quota for Amazon Managed Workflows for Apache Airflow Serverless resources. This can occur when you attempt to create more workflows than allowed, exceed concurrent workflow run limits, or surpass task execution limits. Amazon Managed Workflows for Apache Airflow Serverless implements admission control using DynamoDB-based counters to manage resource utilization across the multi-tenant environment. Contact Amazon Web Services Support to request quota increases if you need higher limits for your use case.

  • ThrottlingException –

    The request was denied because too many requests were made in a short period, exceeding the service rate limits. Amazon Managed Workflows for Apache Airflow Serverless implements throttling controls to ensure fair resource allocation across all customers in the multi-tenant environment. This helps maintain service stability and performance. If you encounter throttling, implement exponential backoff and retry logic in your applications, or consider distributing your API calls over a longer time period.

  • ValidationException –

    The specified request parameters are invalid, missing, or inconsistent with Amazon Managed Workflows for Apache Airflow Serverless service requirements. This can occur when workflow definitions contain unsupported operators, when required IAM permissions are missing, when S3 locations are inaccessible, or when network configurations are invalid. The service validates workflow definitions, execution roles, and resource configurations to ensure compatibility with the managed Airflow environment and security requirements.

  • UnknownServiceError –

    The service returned an error code this client does not model.

Source code in docs_src/capo_mwaa_serverless/_services/mwaa_serverless.py
def create_workflow(
    self,
    name: "capo_mwaa_serverless.types.name_string.NameString",
    definition_s3_location: "capo_mwaa_serverless.types.definition_s3_location.DefinitionS3Location",
    role_arn: "capo_mwaa_serverless.types.role_arn.RoleARN",
    *,
    config_overrides: Optional[MWAAServerlessClientConfig] = None,
    client_token: Optional[
        "capo_mwaa_serverless.types.idempotency_token_string.IdempotencyTokenString"
    ] = None,
    code: Optional["capo_mwaa_serverless.types.code.Code"] = None,
    description: Optional[
        "capo_mwaa_serverless.types.description_string.DescriptionString"
    ] = None,
    encryption_configuration: Optional[
        "capo_mwaa_serverless.types.encryption_configuration.EncryptionConfiguration"
    ] = None,
    logging_configuration: Optional[
        "capo_mwaa_serverless.types.logging_configuration.LoggingConfiguration"
    ] = None,
    engine_version: Optional[
        "capo_mwaa_serverless.types.engine_version.EngineVersion"
    ] = None,
    network_configuration: Optional[
        "capo_mwaa_serverless.types.network_configuration.NetworkConfiguration"
    ] = None,
    tags: Optional["capo_mwaa_serverless.types.tags.Tags"] = None,
    trigger_mode: Optional[
        "capo_mwaa_serverless.types.generic_string.GenericString"
    ] = None,
) -> "capo_mwaa_serverless.types.create_workflow_response.CreateWorkflowResponse":
    """<p>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.</p>

    Args:
        name: <p>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.</p>
        client_token: <p>A unique, case-sensitive identifier that you provide to ensure the idempotency of the request. This token prevents duplicate workflow creation requests.</p>
        definition_s3_location: <p>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.</p>
        code: <p>The location of code artifacts in Amazon S3 for the workflow. The service copies the code from this location at the time of the request.</p>
        role_arn: <p>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.</p>
        description: <p>An optional description of the workflow that you can use to provide additional context about the workflow's purpose and functionality.</p>
        encryption_configuration: <p>The configuration for encrypting workflow data at rest and in transit. Specifies the encryption type and optional KMS key for customer-managed encryption.</p>
        logging_configuration: <p>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.</p>
        engine_version: <p>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.</p>
        network_configuration: <p>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.</p>
        tags: <p>A map of tags to assign to the workflow resource. Tags are key-value pairs that are used for resource organization and cost allocation.</p>
        trigger_mode: <p>The trigger mode for the workflow execution.</p>

    Raises:
        capo_mwaa_serverless.errors.access_denied_exception.AccessDeniedException: <p>You do not have sufficient permission to perform this action.</p>
        capo_mwaa_serverless.errors.conflict_exception.ConflictException: <p>You cannot create a resource that already exists, or the resource is in a state that prevents the requested operation.</p>
        capo_mwaa_serverless.errors.internal_server_exception.InternalServerException: <p>An unexpected server-side error occurred during request processing.</p>
        capo_mwaa_serverless.errors.operation_timeout_exception.OperationTimeoutException: <p>The operation timed out.</p>
        capo_mwaa_serverless.errors.service_quota_exceeded_exception.ServiceQuotaExceededException: <p>The request exceeds the service quota for Amazon Managed Workflows for Apache Airflow Serverless resources. This can occur when you attempt to create more workflows than allowed, exceed concurrent workflow run limits, or surpass task execution limits. Amazon Managed Workflows for Apache Airflow Serverless implements admission control using DynamoDB-based counters to manage resource utilization across the multi-tenant environment. Contact Amazon Web Services Support to request quota increases if you need higher limits for your use case.</p>
        capo_mwaa_serverless.errors.throttling_exception.ThrottlingException: <p>The request was denied because too many requests were made in a short period, exceeding the service rate limits. Amazon Managed Workflows for Apache Airflow Serverless implements throttling controls to ensure fair resource allocation across all customers in the multi-tenant environment. This helps maintain service stability and performance. If you encounter throttling, implement exponential backoff and retry logic in your applications, or consider distributing your API calls over a longer time period.</p>
        capo_mwaa_serverless.errors.validation_exception.ValidationException: <p>The specified request parameters are invalid, missing, or inconsistent with Amazon Managed Workflows for Apache Airflow Serverless service requirements. This can occur when workflow definitions contain unsupported operators, when required IAM permissions are missing, when S3 locations are inaccessible, or when network configurations are invalid. The service validates workflow definitions, execution roles, and resource configurations to ensure compatibility with the managed Airflow environment and security requirements.</p>
        capo_mwaa_serverless.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    def _handler(
        req: "OperationRequest[capo_mwaa_serverless.types.create_workflow_request.CreateWorkflowRequest]",
    ) -> OperationResponse[
        "capo_mwaa_serverless.types.create_workflow_response.CreateWorkflowResponse"
    ]:
        import capo_mwaa_serverless._operations.amazon_mwaa_serverless.create_workflow

        output, http_response = (
            capo_mwaa_serverless._operations.amazon_mwaa_serverless.create_workflow.create_workflow(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("CreateWorkflow")
    )
    input_: capo_mwaa_serverless.types.create_workflow_request.CreateWorkflowRequest = {
        "name": name,
        "definition_s3_location": definition_s3_location,
        "role_arn": role_arn,
    }
    if client_token is None:
        client_token = str(uuid.uuid4())
    input_["client_token"] = client_token
    if code is not None:
        input_["code"] = code
    if description is not None:
        input_["description"] = description
    if encryption_configuration is not None:
        input_["encryption_configuration"] = encryption_configuration
    if logging_configuration is not None:
        input_["logging_configuration"] = logging_configuration
    if engine_version is not None:
        input_["engine_version"] = engine_version
    if network_configuration is not None:
        input_["network_configuration"] = network_configuration
    if tags is not None:
        input_["tags"] = tags
    if trigger_mode is not None:
        input_["trigger_mode"] = trigger_mode

    response = execute_pipeline(
        OperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    response.response.close()
    return response.output