Skip to content

create_task

create_task(
    source_location_arn: LocationArn,
    destination_location_arn: LocationArn,
    *,
    config_overrides: Optional[DataSyncClientConfig] = None,
    cloud_watch_log_group_arn: Optional[LogGroupArn] = None,
    name: Optional[TagValue] = None,
    options: Optional[Options] = None,
    excludes: Optional[FilterList] = None,
    schedule: Optional[TaskSchedule] = None,
    tags: Optional[InputTagList] = None,
    includes: Optional[FilterList] = None,
    manifest_config: Optional[ManifestConfig] = None,
    task_report_config: Optional[TaskReportConfig] = None,
    task_mode: Optional[TaskMode] = None,
) -> CreateTaskResponse

Configures a task, which defines where and how DataSync transfers your data.

A task includes a source location, destination location, and transfer options (such as bandwidth limits, scheduling, and more).

If you're planning to transfer data to or from an Amazon S3 location, review how DataSync can affect your S3 request charges and the DataSync pricing page before you begin.

Parameters:

  • source_location_arn (LocationArn) –

    Specifies the ARN of your transfer's source location.

  • destination_location_arn (LocationArn) –

    Specifies the ARN of your transfer's destination location.

  • cloud_watch_log_group_arn (Optional[LogGroupArn], default: None ) –

    Specifies the Amazon Resource Name (ARN) of an Amazon CloudWatch log group for monitoring your task.

    For Enhanced mode tasks, you don't need to specify anything. DataSync automatically sends logs to a CloudWatch log group named /aws/datasync.

  • name (Optional[TagValue], default: None ) –

    Specifies the name of your task.

  • options (Optional[Options], default: None ) –

    Specifies your task's settings, such as preserving file metadata, verifying data integrity, among other options.

  • excludes (Optional[FilterList], default: None ) –

    Specifies exclude filters that define the files, objects, and folders in your source location that you don't want DataSync to transfer. For more information and examples, see Specifying what DataSync transfers by using filters.

  • schedule (Optional[TaskSchedule], default: None ) –

    Specifies a schedule for when you want your task to run. For more information, see Scheduling your task.

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

    Specifies the tags that you want to apply to your task.

    Tags are key-value pairs that help you manage, filter, and search for your DataSync resources.

  • includes (Optional[FilterList], default: None ) –

    Specifies include filters that define the files, objects, and folders in your source location that you want DataSync to transfer. For more information and examples, see Specifying what DataSync transfers by using filters.

  • manifest_config (Optional[ManifestConfig], default: None ) –

    Configures a manifest, which is a list of files or objects that you want DataSync to transfer. For more information and configuration examples, see Specifying what DataSync transfers by using a manifest.

    When using this parameter, your caller identity (the role that you're using DataSync with) must have the iam:PassRole permission. The AWSDataSyncFullAccess policy includes this permission.

  • task_report_config (Optional[TaskReportConfig], default: None ) –

    Specifies how you want to configure a task report, which provides detailed information about your DataSync transfer. For more information, see Monitoring your DataSync transfers with task reports.

    When using this parameter, your caller identity (the role that you're using DataSync with) must have the iam:PassRole permission. The AWSDataSyncFullAccess policy includes this permission.

  • task_mode (Optional[TaskMode], default: None ) –

    Specifies one of the following task modes for your data transfer:

    • ENHANCED - Transfer virtually unlimited numbers of objects with higher performance than Basic mode. Enhanced mode tasks optimize the data transfer process by listing, preparing, transferring, and verifying data in parallel. Enhanced mode is currently available for transfers between Amazon S3 locations, transfers between Azure Blob and Amazon S3 without an agent, and transfers between other clouds and Amazon S3 without an agent.

      To create an Enhanced mode task, the IAM role that you use to call the CreateTask operation must have the iam:CreateServiceLinkedRole permission.

    • BASIC (default) - Transfer files or objects between Amazon Web Services storage and all other supported DataSync locations. Basic mode tasks are subject to quotas on the number of files, objects, and directories in a dataset. Basic mode sequentially prepares, transfers, and verifies data, making it slower than Enhanced mode for most workloads.

    For more information, see Understanding task mode differences.

Raises:

Source code in docs_src/capo_datasync/_services/data_sync.py
def create_task(
    self,
    source_location_arn: "capo_datasync.types.location_arn.LocationArn",
    destination_location_arn: "capo_datasync.types.location_arn.LocationArn",
    *,
    config_overrides: Optional[DataSyncClientConfig] = None,
    cloud_watch_log_group_arn: Optional[
        "capo_datasync.types.log_group_arn.LogGroupArn"
    ] = None,
    name: Optional["capo_datasync.types.tag_value.TagValue"] = None,
    options: Optional["capo_datasync.types.options.Options"] = None,
    excludes: Optional["capo_datasync.types.filter_list.FilterList"] = None,
    schedule: Optional["capo_datasync.types.task_schedule.TaskSchedule"] = None,
    tags: Optional["capo_datasync.types.input_tag_list.InputTagList"] = None,
    includes: Optional["capo_datasync.types.filter_list.FilterList"] = None,
    manifest_config: Optional[
        "capo_datasync.types.manifest_config.ManifestConfig"
    ] = None,
    task_report_config: Optional[
        "capo_datasync.types.task_report_config.TaskReportConfig"
    ] = None,
    task_mode: Optional["capo_datasync.types.task_mode.TaskMode"] = None,
) -> "capo_datasync.types.create_task_response.CreateTaskResponse":
    """<p>Configures a <i>task</i>, which defines where and how DataSync transfers your data.</p> <p>A task includes a source location, destination location, and transfer options (such as bandwidth limits, scheduling, and more).</p> <important> <p>If you're planning to transfer data to or from an Amazon S3 location, review <a href="https://docs.aws.amazon.com/datasync/latest/userguide/create-s3-location.html#create-s3-location-s3-requests">how DataSync can affect your S3 request charges</a> and the <a href="http://aws.amazon.com/datasync/pricing/">DataSync pricing page</a> before you begin.</p> </important>

    Args:
        source_location_arn: <p>Specifies the ARN of your transfer's source location.</p>
        destination_location_arn: <p>Specifies the ARN of your transfer's destination location. </p>
        cloud_watch_log_group_arn: <p>Specifies the Amazon Resource Name (ARN) of an Amazon CloudWatch log group for monitoring your task.</p> <p>For Enhanced mode tasks, you don't need to specify anything. DataSync automatically sends logs to a CloudWatch log group named <code>/aws/datasync</code>.</p>
        name: <p>Specifies the name of your task.</p>
        options: <p>Specifies your task's settings, such as preserving file metadata, verifying data integrity, among other options.</p>
        excludes: <p>Specifies exclude filters that define the files, objects, and folders in your source location that you don't want DataSync to transfer. For more information and examples, see <a href="https://docs.aws.amazon.com/datasync/latest/userguide/filtering.html">Specifying what DataSync transfers by using filters</a>.</p>
        schedule: <p>Specifies a schedule for when you want your task to run. For more information, see <a href="https://docs.aws.amazon.com/datasync/latest/userguide/task-scheduling.html">Scheduling your task</a>.</p>
        tags: <p>Specifies the tags that you want to apply to your task.</p> <p> <i>Tags</i> are key-value pairs that help you manage, filter, and search for your DataSync resources.</p>
        includes: <p>Specifies include filters that define the files, objects, and folders in your source location that you want DataSync to transfer. For more information and examples, see <a href="https://docs.aws.amazon.com/datasync/latest/userguide/filtering.html">Specifying what DataSync transfers by using filters</a>.</p>
        manifest_config: <p>Configures a manifest, which is a list of files or objects that you want DataSync to transfer. For more information and configuration examples, see <a href="https://docs.aws.amazon.com/datasync/latest/userguide/transferring-with-manifest.html">Specifying what DataSync transfers by using a manifest</a>.</p> <p>When using this parameter, your caller identity (the role that you're using DataSync with) must have the <code>iam:PassRole</code> permission. The <a href="https://docs.aws.amazon.com/datasync/latest/userguide/security-iam-awsmanpol.html#security-iam-awsmanpol-awsdatasyncfullaccess">AWSDataSyncFullAccess</a> policy includes this permission.</p>
        task_report_config: <p>Specifies how you want to configure a task report, which provides detailed information about your DataSync transfer. For more information, see <a href="https://docs.aws.amazon.com/datasync/latest/userguide/task-reports.html">Monitoring your DataSync transfers with task reports</a>.</p> <p>When using this parameter, your caller identity (the role that you're using DataSync with) must have the <code>iam:PassRole</code> permission. The <a href="https://docs.aws.amazon.com/datasync/latest/userguide/security-iam-awsmanpol.html#security-iam-awsmanpol-awsdatasyncfullaccess">AWSDataSyncFullAccess</a> policy includes this permission.</p>
        task_mode: <p>Specifies one of the following task modes for your data transfer:</p> <ul> <li> <p> <code>ENHANCED</code> - Transfer virtually unlimited numbers of objects with higher performance than Basic mode. Enhanced mode tasks optimize the data transfer process by listing, preparing, transferring, and verifying data in parallel. Enhanced mode is currently available for transfers between Amazon S3 locations, transfers between Azure Blob and Amazon S3 without an agent, and transfers between other clouds and Amazon S3 without an agent.</p> <note> <p>To create an Enhanced mode task, the IAM role that you use to call the <code>CreateTask</code> operation must have the <code>iam:CreateServiceLinkedRole</code> permission.</p> </note> </li> <li> <p> <code>BASIC</code> (default) - Transfer files or objects between Amazon Web Services storage and all other supported DataSync locations. Basic mode tasks are subject to <a href="https://docs.aws.amazon.com/datasync/latest/userguide/datasync-limits.html">quotas</a> on the number of files, objects, and directories in a dataset. Basic mode sequentially prepares, transfers, and verifies data, making it slower than Enhanced mode for most workloads.</p> </li> </ul> <p>For more information, see <a href="https://docs.aws.amazon.com/datasync/latest/userguide/choosing-task-mode.html#task-mode-differences">Understanding task mode differences</a>.</p>

    Raises:
        capo_datasync.errors.internal_exception.InternalException: <p>This exception is thrown when an error occurs in the DataSync service.</p>
        capo_datasync.errors.invalid_request_exception.InvalidRequestException: <p>This exception is thrown when the client submits a malformed request.</p>
        capo_datasync.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    def _handler(
        req: "OperationRequest[capo_datasync.types.create_task_request.CreateTaskRequest]",
    ) -> OperationResponse[
        "capo_datasync.types.create_task_response.CreateTaskResponse"
    ]:
        import capo_datasync._operations.fmrs_service.create_task

        output, http_response = (
            capo_datasync._operations.fmrs_service.create_task.create_task(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("CreateTask")
    )
    input_: capo_datasync.types.create_task_request.CreateTaskRequest = {
        "source_location_arn": source_location_arn,
        "destination_location_arn": destination_location_arn,
    }
    if cloud_watch_log_group_arn is not None:
        input_["cloud_watch_log_group_arn"] = cloud_watch_log_group_arn
    if name is not None:
        input_["name"] = name
    if options is not None:
        input_["options"] = options
    if excludes is not None:
        input_["excludes"] = excludes
    if schedule is not None:
        input_["schedule"] = schedule
    if tags is not None:
        input_["tags"] = tags
    if includes is not None:
        input_["includes"] = includes
    if manifest_config is not None:
        input_["manifest_config"] = manifest_config
    if task_report_config is not None:
        input_["task_report_config"] = task_report_config
    if task_mode is not None:
        input_["task_mode"] = task_mode

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