- Navigation GuideYou are on a Command (operation) page with structural examples. Use the navigation breadcrumb if you would like to return to the Client landing page.
CreateTaskCommand
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.
Example Syntax
Use a bare-bones client and the command you need to make an API call.
import { DataSyncClient, CreateTaskCommand } from "@aws-sdk/client-datasync"; // ES Modules import
// const { DataSyncClient, CreateTaskCommand } = require("@aws-sdk/client-datasync"); // CommonJS import
const client = new DataSyncClient(config);
const input = { // CreateTaskRequest
SourceLocationArn: "STRING_VALUE", // required
DestinationLocationArn: "STRING_VALUE", // required
CloudWatchLogGroupArn: "STRING_VALUE",
Name: "STRING_VALUE",
Options: { // Options
VerifyMode: "POINT_IN_TIME_CONSISTENT" || "ONLY_FILES_TRANSFERRED" || "NONE",
OverwriteMode: "ALWAYS" || "NEVER",
Atime: "NONE" || "BEST_EFFORT",
Mtime: "NONE" || "PRESERVE",
Uid: "NONE" || "INT_VALUE" || "NAME" || "BOTH",
Gid: "NONE" || "INT_VALUE" || "NAME" || "BOTH",
PreserveDeletedFiles: "PRESERVE" || "REMOVE",
PreserveDevices: "NONE" || "PRESERVE",
PosixPermissions: "NONE" || "PRESERVE",
BytesPerSecond: Number("long"),
TaskQueueing: "ENABLED" || "DISABLED",
LogLevel: "OFF" || "BASIC" || "TRANSFER",
TransferMode: "CHANGED" || "ALL",
SecurityDescriptorCopyFlags: "NONE" || "OWNER_DACL" || "OWNER_DACL_SACL",
ObjectTags: "PRESERVE" || "NONE",
},
Excludes: [ // FilterList
{ // FilterRule
FilterType: "SIMPLE_PATTERN",
Value: "STRING_VALUE",
},
],
Schedule: { // TaskSchedule
ScheduleExpression: "STRING_VALUE", // required
Status: "ENABLED" || "DISABLED",
},
Tags: [ // InputTagList
{ // TagListEntry
Key: "STRING_VALUE", // required
Value: "STRING_VALUE",
},
],
Includes: [
{
FilterType: "SIMPLE_PATTERN",
Value: "STRING_VALUE",
},
],
ManifestConfig: { // ManifestConfig
Action: "TRANSFER",
Format: "CSV",
Source: { // SourceManifestConfig
S3: { // S3ManifestConfig
ManifestObjectPath: "STRING_VALUE", // required
BucketAccessRoleArn: "STRING_VALUE", // required
S3BucketArn: "STRING_VALUE", // required
ManifestObjectVersionId: "STRING_VALUE",
},
},
},
TaskReportConfig: { // TaskReportConfig
Destination: { // ReportDestination
S3: { // ReportDestinationS3
Subdirectory: "STRING_VALUE",
S3BucketArn: "STRING_VALUE", // required
BucketAccessRoleArn: "STRING_VALUE", // required
},
},
OutputType: "SUMMARY_ONLY" || "STANDARD",
ReportLevel: "ERRORS_ONLY" || "SUCCESSES_AND_ERRORS",
ObjectVersionIds: "INCLUDE" || "NONE",
Overrides: { // ReportOverrides
Transferred: { // ReportOverride
ReportLevel: "ERRORS_ONLY" || "SUCCESSES_AND_ERRORS",
},
Verified: {
ReportLevel: "ERRORS_ONLY" || "SUCCESSES_AND_ERRORS",
},
Deleted: {
ReportLevel: "ERRORS_ONLY" || "SUCCESSES_AND_ERRORS",
},
Skipped: {
ReportLevel: "ERRORS_ONLY" || "SUCCESSES_AND_ERRORS",
},
},
},
TaskMode: "BASIC" || "ENHANCED",
};
const command = new CreateTaskCommand(input);
const response = await client.send(command);
// { // CreateTaskResponse
// TaskArn: "STRING_VALUE",
// };
CreateTaskCommand Input
Parameter | Type | Description |
---|
Parameter | Type | Description |
---|---|---|
DestinationLocationArn Required | string | undefined | Specifies the ARN of your transfer's destination location. |
SourceLocationArn Required | string | undefined | Specifies the ARN of your transfer's source location. |
CloudWatchLogGroupArn | string | undefined | 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 |
Excludes | FilterRule[] | undefined | 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 . |
Includes | FilterRule[] | undefined | 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 . |
ManifestConfig | ManifestConfig | undefined | 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 |
Name | string | undefined | Specifies the name of your task. |
Options | Options | undefined | Specifies your task's settings, such as preserving file metadata, verifying data integrity, among other options. |
Schedule | TaskSchedule | undefined | Specifies a schedule for when you want your task to run. For more information, see Scheduling your task . |
Tags | TagListEntry[] | undefined | 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. |
TaskMode | TaskMode | undefined | Specifies one of the following task modes for your data transfer:
For more information, see Understanding task mode differences . |
TaskReportConfig | TaskReportConfig | undefined | 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 |
CreateTaskCommand Output
Parameter | Type | Description |
---|
Parameter | Type | Description |
---|---|---|
$metadata Required | ResponseMetadata | Metadata pertaining to this request. |
TaskArn | string | undefined | The Amazon Resource Name (ARN) of the task. |
Throws
Name | Fault | Details |
---|
Name | Fault | Details |
---|---|---|
InternalException | server | This exception is thrown when an error occurs in the DataSync service. |
InvalidRequestException | client | This exception is thrown when the client submits a malformed request. |
DataSyncServiceException | Base exception class for all service exceptions from DataSync service. |