CreateTask
Configures a task, which defines where and how AWS 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
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
"
}
],
"TaskMode": "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 Enhanced mode tasks, you don't need to specify anything. DataSync automatically sends logs to a CloudWatch log group named
/aws/datasync
.For more information, see Monitoring data transfers with CloudWatch Logs.
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 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.
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
- TaskMode
-
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.Note
To create an Enhanced mode task, the IAM role that you use to call the
CreateTask
operation must have theiam:CreateServiceLinkedRole
permission. -
BASIC
(default) - Transfer files or objects between AWS 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.
Type: String
Valid Values:
BASIC | ENHANCED
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 AWS 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 for an Enhanced mode task
The following example creates a DataSync task that uses Enhanced mode.
Unlike when creating Basic mode tasks, you don't have to specify an Amazon CloudWatch log group. With Enhanced mode tasks, DataSync automatically
sends task logs to a log group named /aws/datasync
. If that log group
doesn't exist in your AWS Region, DataSync creates the log group on your behalf
when you create the task.
{ "SourceLocationArn": "arn:aws:datasync:us-east-1:111222333444:location/1111aaaa2222bbbb3", "DestinationLocationArn": "arn:aws:datasync:us-east-1:111222333444:location/0000zzzz1111yyyy2", "Name": "My Enhanced mode task", "TaskMode": "ENHANCED", "Options": { "TransferMode": "CHANGED", "VerifyMode": "ONLY_FILES_TRANSFERRED", "ObjectTags": "PRESERVE", "LogLevel": "TRANSFER" } }
Sample Request for a Basic mode task
The following example creates a DataSync task that uses Basic mode.
{ "SourceLocationArn": "arn:aws:datasync:us-east-2:111222333444:location/loc-1111aaaa2222bbbb3", "DestinationLocationArn": "arn:aws:datasync:us-east-2:111222333444:location/loc-0000zzzz1111yyyy2", "Name": "My Basic mode task", "TaskMode": "BASIC", "Options": { "Atime": "BEST_EFFORT", "Gid": "NONE", "Mtime": "PRESERVE", "PosixPermissions": "PRESERVE", "PreserveDevices": "NONE", "PreserveDeletedFiles": "PRESERVE", "Uid": "NONE", "VerifyMode": "ONLY_FILES_TRANSFERRED" }, "Schedule": { "ScheduleExpression": "0 12 ? * SUN,WED *" }, "CloudWatchLogGroupArn": "arn:aws:logs:us-east-2:111222333444:log-group:/log-group-name:*", "Tags": [ { "Key": "Name", "Value": "Migration-wave-1" } ] }
Sample Response
The following response includes the ARN of a created 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 AWS SDKs, see the following: