Skip to content

Resource: awsDatasyncTask

Manages an AWS DataSync Task, which represents a configuration for synchronization. Starting an execution of these DataSync Tasks (actually synchronizing files) is performed outside of this Terraform resource.

Example Usage

/*Provider bindings are generated by running cdktf get.
See https://cdk.tf/provider-generation for more details.*/
import * as aws from "./.gen/providers/aws";
new aws.datasyncTask.DatasyncTask(this, "example", {
  destinationLocationArn: "${aws_datasync_location_s3.destination.arn}",
  name: "example",
  options: {
    bytesPerSecond: -1,
  },
  sourceLocationArn: "${aws_datasync_location_nfs.source.arn}",
});

Example Usage with Scheduling

/*Provider bindings are generated by running cdktf get.
See https://cdk.tf/provider-generation for more details.*/
import * as aws from "./.gen/providers/aws";
new aws.datasyncTask.DatasyncTask(this, "example", {
  destinationLocationArn: "${aws_datasync_location_s3.destination.arn}",
  name: "example",
  schedule: {
    scheduleExpression: "cron(0 12 ? * SUN,WED *)",
  },
  sourceLocationArn: "${aws_datasync_location_nfs.source.arn}",
});

Example Usage with Filtering

/*Provider bindings are generated by running cdktf get.
See https://cdk.tf/provider-generation for more details.*/
import * as aws from "./.gen/providers/aws";
new aws.datasyncTask.DatasyncTask(this, "example", {
  destinationLocationArn: "${aws_datasync_location_s3.destination.arn}",
  excludes: {
    filterType: "SIMPLE_PATTERN",
    value: "/folder1|/folder2",
  },
  includes: {
    filterType: "SIMPLE_PATTERN",
    value: "/folder1|/folder2",
  },
  name: "example",
  sourceLocationArn: "${aws_datasync_location_nfs.source.arn}",
});

Argument Reference

The following arguments are supported:

  • destinationLocationArn - (Required) Amazon Resource Name (ARN) of destination DataSync Location.
  • sourceLocationArn - (Required) Amazon Resource Name (ARN) of source DataSync Location.
  • cloudwatchLogGroupArn - (Optional) Amazon Resource Name (ARN) of the CloudWatch Log Group that is used to monitor and log events in the sync task.
  • excludes - (Optional) Filter rules that determines which files to exclude from a task.
  • includes - (Optional) Filter rules that determines which files to include in a task.
  • name - (Optional) Name of the DataSync Task.
  • options - (Optional) Configuration block containing option that controls the default behavior when you start an execution of this DataSync Task. For each individual task execution, you can override these options by specifying an overriding configuration in those executions.
  • schedule - (Optional) Specifies a schedule used to periodically transfer files from a source to a destination location.
  • tags - (Optional) Key-value pairs of resource tags to assign to the DataSync Task. If configured with a provider defaultTags configuration block present, tags with matching keys will overwrite those defined at the provider-level.

options Argument Reference

\~> NOTE: If atime is set to BEST_EFFORT, mtime must be set to preserve. If atime is set to none, mtime must be set to none.

The following arguments are supported inside the options configuration block:

  • atime - (Optional) A file metadata that shows the last time a file was accessed (that is when the file was read or written to). If set to BEST_EFFORT, the DataSync Task attempts to preserve the original (that is, the version before sync preparing phase) atime attribute on all source files. Valid values: BEST_EFFORT, none. Default: BEST_EFFORT.
  • bytesPerSecond - (Optional) Limits the bandwidth utilized. For example, to set a maximum of 1 MB, set this value to 1048576. Value values: 1 or greater. Default: 1 (unlimited).
  • gid - (Optional) Group identifier of the file's owners. Valid values: both, INT_VALUE, name, none. Default: INT_VALUE (preserve integer value of the ID).
  • logLevel - (Optional) Determines the type of logs that DataSync publishes to a log stream in the Amazon CloudWatch log group that you provide. Valid values: off, basic, transfer. Default: off.
  • mtime - (Optional) A file metadata that indicates the last time a file was modified (written to) before the sync preparing phase. Value values: none, preserve. Default: preserve.
  • overwriteMode - (Optional) Determines whether files at the destination should be overwritten or preserved when copying files. Valid values: always, never. Default: always.
  • posixPermissions - (Optional) Determines which users or groups can access a file for a specific purpose such as reading, writing, or execution of the file. Valid values: none, preserve. Default: preserve.
  • preserveDeletedFiles - (Optional) Whether files deleted in the source should be removed or preserved in the destination file system. Valid values: preserve, remove. Default: preserve.
  • preserveDevices - (Optional) Whether the DataSync Task should preserve the metadata of block and character devices in the source files system, and recreate the files with that device name and metadata on the destination. The DataSync Task can’t sync the actual contents of such devices, because many of the devices are non-terminal and don’t return an end of file (EOF) marker. Valid values: none, preserve. Default: none (ignore special devices).
  • securityDescriptorCopyFlags - (Optional) Determines which components of the SMB security descriptor are copied from source to destination objects. This value is only used for transfers between SMB and Amazon FSx for Windows File Server locations, or between two Amazon FSx for Windows File Server locations. Valid values: none, OWNER_DACL, OWNER_DACL_SACL.
  • taskQueueing - (Optional) Determines whether tasks should be queued before executing the tasks. Valid values: enabled, disabled. Default enabled.
  • transferMode - (Optional) Determines whether DataSync transfers only the data and metadata that differ between the source and the destination location, or whether DataSync transfers all the content from the source, without comparing to the destination location. Valid values: changed, all. Default: changed
  • uid - (Optional) User identifier of the file's owners. Valid values: both, INT_VALUE, name, none. Default: INT_VALUE (preserve integer value of the ID).
  • verifyMode - (Optional) Whether a data integrity verification should be performed at the end of a task execution after all data and metadata have been transferred. Valid values: none, POINT_IN_TIME_CONSISTENT, ONLY_FILES_TRANSFERRED. Default: POINT_IN_TIME_CONSISTENT.

Schedule

  • scheduleExpression - (Required) Specifies the schedule you want your task to use for repeated executions. For more information, see Schedule Expressions for Rules.

excludes Argument Reference

  • filterType - (Optional) The type of filter rule to apply. Valid values: SIMPLE_PATTERN.
  • value - (Optional) A single filter string that consists of the patterns to exclude. The patterns are delimited by "|" (that is, a pipe), for example: /folder1|/folder2

includes Argument Reference

  • filterType - (Optional) The type of filter rule to apply. Valid values: SIMPLE_PATTERN.
  • value - (Optional) A single filter string that consists of the patterns to include. The patterns are delimited by "|" (that is, a pipe), for example: /folder1|/folder2

Attributes Reference

In addition to all arguments above, the following attributes are exported:

  • id - Amazon Resource Name (ARN) of the DataSync Task.
  • arn - Amazon Resource Name (ARN) of the DataSync Task.
  • tagsAll - A map of tags assigned to the resource, including those inherited from the provider defaultTags configuration block.

Timeouts

Configuration options:

  • create - (Default 5M)

Import

awsDatasyncTask can be imported by using the DataSync Task Amazon Resource Name (ARN), e.g.,

$ terraform import aws_datasync_task.example arn:aws:datasync:us-east-1:123456789012:task/task-12345678901234567