CreateTask
Configures a transfer task, which defines where and how Amazon DataSync moves your data.
A task includes a source location, destination location, and the options for how and when you want to transfer your data (such as bandwidth limits, scheduling, among other options).
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
"
}
],
"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
"
},
"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
-
The Amazon Resource Name (ARN) of the Amazon CloudWatch log group that is used to monitor and log events in the task.
For more information about how to use CloudWatch Logs with DataSync, see Monitoring Your Task in the Amazon DataSync User Guide.
For more information about these groups, see Working with Log Groups and Log Streams in the Amazon CloudWatch Logs User Guide.
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
-
The Amazon Resource Name (ARN) of an Amazon storage resource's 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 a list of filter rules that exclude specific data during your transfer. For more information and examples, see Filtering data transferred by DataSync.
Type: Array of FilterRule objects
Array Members: Minimum number of 0 items. Maximum number of 1 item.
Required: No
- Includes
-
Specifies a list of filter rules that include specific data during your transfer. For more information and examples, see Filtering data transferred by DataSync.
Type: Array of FilterRule objects
Array Members: Minimum number of 0 items. Maximum number of 1 item.
Required: No
- Name
-
The name of a task. This value is a text reference that is used to identify the task in the console.
Type: String
Length Constraints: Minimum length of 1. Maximum length of 256.
Pattern:
^[a-zA-Z0-9\s+=._:@/-]+$
Required: No
- Options
-
Specifies the configuration options for a task. Some options include preserving file or object metadata and verifying data integrity.
You can also override these options before starting an individual run of a task (also known as a task execution). For more information, see StartTaskExecution.
Type: Options object
Required: No
- Schedule
-
Specifies a schedule used to periodically transfer files from a source to a destination location. The schedule should be specified in UTC time. For more information, see Scheduling your task.
Type: TaskSchedule object
Required: No
- SourceLocationArn
-
The Amazon Resource Name (ARN) of the source location for 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}:location/loc-[0-9a-z]{17}$
Required: Yes
- Tags
-
Specifies the tags that you want to apply to the Amazon Resource Name (ARN) representing the 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 for your DataSync transfer.
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 using a source and destination locations.
{ "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 returns 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: