CreateTask - Amazon DataSync
Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions, see Getting Started with Amazon Web Services in China (PDF).

CreateTask

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

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

Important

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.

Request Syntax

{ "CloudWatchLogGroupArn": "string", "DestinationLocationArn": "string", "Excludes": [ { "FilterType": "string", "Value": "string" } ], "Includes": [ { "FilterType": "string", "Value": "string" } ], "ManifestConfig": { "Action": "string", "Format": "string", "Source": { "S3": { "BucketAccessRoleArn": "string", "ManifestObjectPath": "string", "ManifestObjectVersionId": "string", "S3BucketArn": "string" } } }, "Name": "string", "Options": { "Atime": "string", "BytesPerSecond": number, "Gid": "string", "LogLevel": "string", "Mtime": "string", "ObjectTags": "string", "OverwriteMode": "string", "PosixPermissions": "string", "PreserveDeletedFiles": "string", "PreserveDevices": "string", "SecurityDescriptorCopyFlags": "string", "TaskQueueing": "string", "TransferMode": "string", "Uid": "string", "VerifyMode": "string" }, "Schedule": { "ScheduleExpression": "string", "Status": "string" }, "SourceLocationArn": "string", "Tags": [ { "Key": "string", "Value": "string" } ], "TaskReportConfig": { "Destination": { "S3": { "BucketAccessRoleArn": "string", "S3BucketArn": "string", "Subdirectory": "string" } }, "ObjectVersionIds": "string", "OutputType": "string", "Overrides": { "Deleted": { "ReportLevel": "string" }, "Skipped": { "ReportLevel": "string" }, "Transferred": { "ReportLevel": "string" }, "Verified": { "ReportLevel": "string" } }, "ReportLevel": "string" } }

Request Parameters

For information about the parameters that are common to all actions, see Common Parameters.

The request accepts the following data in JSON format.

CloudWatchLogGroupArn

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

For more information, see Monitoring DataSync with Amazon CloudWatch.

Type: String

Length Constraints: Maximum length of 562.

Pattern: ^arn:(aws|aws-cn|aws-us-gov|aws-iso|aws-iso-b):logs:[a-z\-0-9]+:[0-9]{12}:log-group:([^:\*]*)(:\*)?$

Required: No

DestinationLocationArn

Specifies the ARN of your transfer's destination location.

Type: String

Length Constraints: Maximum length of 128.

Pattern: ^arn:(aws|aws-cn|aws-us-gov|aws-iso|aws-iso-b):datasync:[a-z\-0-9]+:[0-9]{12}:location/loc-[0-9a-z]{17}$

Required: Yes

Excludes

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.

Type: Array of FilterRule objects

Array Members: Minimum number of 0 items. Maximum number of 1 item.

Required: No

Includes

Specifies include filters 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.

Type: Array of FilterRule objects

Array Members: Minimum number of 0 items. Maximum number of 1 item.

Required: No

ManifestConfig

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.

Type: ManifestConfig object

Required: No

Name

Specifies the name of your task.

Type: String

Length Constraints: Minimum length of 0. Maximum length of 256.

Pattern: ^[a-zA-Z0-9\s+=._:@/-]+$

Required: No

Options

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

Type: Options object

Required: No

Schedule

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

Type: TaskSchedule object

Required: No

SourceLocationArn

Specifies the ARN of your transfer's source location.

Type: String

Length Constraints: Maximum length of 128.

Pattern: ^arn:(aws|aws-cn|aws-us-gov|aws-iso|aws-iso-b):datasync:[a-z\-0-9]+:[0-9]{12}:location/loc-[0-9a-z]{17}$

Required: Yes

Tags

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.

Type: Array of TagListEntry objects

Array Members: Minimum number of 0 items. Maximum number of 50 items.

Required: No

TaskReportConfig

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.

Type: TaskReportConfig object

Required: No

Response Syntax

{ "TaskArn": "string" }

Response Elements

If the action is successful, the service sends back an HTTP 200 response.

The following data is returned in JSON format by the service.

TaskArn

The Amazon Resource Name (ARN) of the task.

Type: String

Length Constraints: Maximum length of 128.

Pattern: ^arn:(aws|aws-cn|aws-us-gov|aws-iso|aws-iso-b):datasync:[a-z\-0-9]*:[0-9]{12}:task/task-[0-9a-f]{17}$

Errors

For information about the errors that are common to all actions, see Common Errors.

InternalException

This exception is thrown when an error occurs in the Amazon DataSync service.

HTTP Status Code: 500

InvalidRequestException

This exception is thrown when the client submits a malformed request.

HTTP Status Code: 400

Examples

Sample Request

The following example creates a task.

{ "Options": { "Atime": "BEST_EFFORT", "Gid": "NONE", "Mtime": "PRESERVE", "PosixPermissions": "PRESERVE", "PreserveDevices": "NONE", "PreserveDeletedFiles": "PRESERVE", "Uid": "NONE", "VerifyMode": "POINT_IN_TIME_CONSISTENT" }, "Schedule": { "ScheduleExpression": "0 12 ? * SUN,WED *" }, "CloudWatchLogGroupArn": "arn:aws:logs:us-east-2:111222333444:log-group", "DestinationLocationArn": "arn:aws:datasync:us-east-2:111222333444:location/loc-07db7abfc326c50fb", "Name": "MyTask", "SourceLocationArn": "arn:aws:datasync:us-east-2:111222333444:location/loc-0f01451b140b2af49", "Tags": [{ "Key": "Name", "Value": "Task-1" }] }

Sample Response

The following response includes the Amazon Resource Name (ARN) of the task.

{ "TaskArn": "arn:aws:datasync:us-east-2:111222333444:task/task-08de6e6697796f026" }

See Also

For more information about using this API in one of the language-specific Amazon SDKs, see the following: