AWS.DataSync reference
CancelTaskExecution
Section titled “CancelTaskExecution”Source:
src/AWS/DataSync/CancelTaskExecution.ts
Runtime binding for datasync:CancelTaskExecution.
Stops a queued or in-flight execution of the bound Task — e.g. a
kill switch when a transfer was started by mistake or is saturating a
link. Address the execution with the ARN returned by
StartTaskExecution; access is granted on the bound task’s executions.
Provide the implementation with
Effect.provide(AWS.DataSync.CancelTaskExecutionHttp).
CancelTaskExecution: Running Transfers
Section titled “CancelTaskExecution: Running Transfers”// init — bind the operation to the taskconst cancelTaskExecution = yield* AWS.DataSync.CancelTaskExecution(task);
// runtimeyield* cancelTaskExecution({ TaskExecutionArn: executionArn });DescribeTask
Section titled “DescribeTask”Source:
src/AWS/DataSync/DescribeTask.ts
Runtime binding for datasync:DescribeTask.
Reads the bound Task’s full detail — status, transfer options,
filters, schedule (including ScheduleDetails with the last disable
reason), and the ARN of the currently running execution — so an ops
function can monitor the task’s health. The task ARN is injected from the
binding. Provide the implementation with
Effect.provide(AWS.DataSync.DescribeTaskHttp).
DescribeTask: Monitoring Tasks
Section titled “DescribeTask: Monitoring Tasks”// init — bind the operation to the taskconst describeTask = yield* AWS.DataSync.DescribeTask(task);
// runtimeconst detail = yield* describeTask();yield* Effect.log(`task ${detail.Name} is ${detail.Status}`);DescribeTaskExecution
Section titled “DescribeTaskExecution”Source:
src/AWS/DataSync/DescribeTaskExecution.ts
Runtime binding for datasync:DescribeTaskExecution.
Reads one execution of the bound Task — status, bytes/files
transferred, per-phase results — to monitor an ongoing transfer or check
a finished one. Address the execution with the ARN returned by
StartTaskExecution; access is granted on the bound task’s executions.
Provide the implementation with
Effect.provide(AWS.DataSync.DescribeTaskExecutionHttp).
DescribeTaskExecution: Running Transfers
Section titled “DescribeTaskExecution: Running Transfers”// init — bind the operation to the taskconst describeTaskExecution = yield* AWS.DataSync.DescribeTaskExecution(task);
// runtimeconst execution = yield* describeTaskExecution({ TaskExecutionArn: executionArn,});yield* Effect.log(`${execution.Status}: ${execution.BytesTransferred} bytes`);ListTaskExecutions
Section titled “ListTaskExecutions”Source:
src/AWS/DataSync/ListTaskExecutions.ts
Runtime binding for datasync:ListTaskExecutions.
Enumerates the bound Task’s executions (most recent first) so an
ops function can audit run history or find the latest run’s ARN. The task
ARN is injected from the binding; pass MaxResults/NextToken to page.
Provide the implementation with
Effect.provide(AWS.DataSync.ListTaskExecutionsHttp).
ListTaskExecutions: Monitoring Tasks
Section titled “ListTaskExecutions: Monitoring Tasks”// init — bind the operation to the taskconst listTaskExecutions = yield* AWS.DataSync.ListTaskExecutions(task);
// runtimeconst { TaskExecutions } = yield* listTaskExecutions();for (const execution of TaskExecutions ?? []) { yield* Effect.log(`${execution.TaskExecutionArn}: ${execution.Status}`);}LocationEfs
Section titled “LocationEfs”Source:
src/AWS/DataSync/LocationEfs.ts
A DataSync location backed by an Amazon EFS file system. Used as a source
or destination endpoint of a Task.
EFS locations are immutable apart from their tags: any change to the file system, subnet, security groups, subdirectory, access point, or encryption replaces the location.
LocationEfs: Creating EFS Locations
Section titled “LocationEfs: Creating EFS Locations”import * as AWS from "alchemy/AWS";
const location = yield* AWS.DataSync.LocationEfs("Files", { efsFilesystemArn: files.fileSystemArn, subnetArn: `arn:aws:ec2:${region}:${accountId}:subnet/${subnetId}`, securityGroupArns: [ `arn:aws:ec2:${region}:${accountId}:security-group/${sgId}`, ],});LocationEfs: Transferring Data
Section titled “LocationEfs: Transferring Data”const dest = yield* AWS.DataSync.LocationS3("Backups", { s3BucketArn: bucket.bucketArn, bucketAccessRoleArn: role.roleArn,});
const task = yield* AWS.DataSync.Task("EfsBackup", { sourceLocationArn: location.locationArn, destinationLocationArn: dest.locationArn, schedule: { ScheduleExpression: "cron(0 2 * * ? *)" },});LocationS3
Section titled “LocationS3”Source:
src/AWS/DataSync/LocationS3.ts
A DataSync location backed by an Amazon S3 bucket. Locations are the
source and destination endpoints referenced by a Task.
S3 locations are immutable apart from their tags: any change to the
bucket, subdirectory, storage class, or access role replaces the location.
Reconcile is idempotent across state loss — the location is re-discovered
by its deterministic s3://… URI.
LocationS3: Creating S3 Locations
Section titled “LocationS3: Creating S3 Locations”Bucket root
import * as AWS from "alchemy/AWS";
const source = yield* AWS.DataSync.LocationS3("Source", { s3BucketArn: bucket.bucketArn, bucketAccessRoleArn: role.roleArn,});Prefix + storage class
const dest = yield* AWS.DataSync.LocationS3("Dest", { s3BucketArn: bucket.bucketArn, bucketAccessRoleArn: role.roleArn, subdirectory: "/archive", s3StorageClass: "STANDARD_IA",});StartTaskExecution
Section titled “StartTaskExecution”Source:
src/AWS/DataSync/StartTaskExecution.ts
Runtime binding for datasync:StartTaskExecution.
Starts a run of the bound Task — the moment data actually moves.
The task ARN is injected from the binding; pass OverrideOptions,
Includes/Excludes, or a ManifestConfig to shape the individual run.
Returns the new execution’s ARN for use with DescribeTaskExecution /
CancelTaskExecution. Provide the implementation with
Effect.provide(AWS.DataSync.StartTaskExecutionHttp).
StartTaskExecution: Running Transfers
Section titled “StartTaskExecution: Running Transfers”// init — bind the operation to the taskconst startTaskExecution = yield* AWS.DataSync.StartTaskExecution(task);
// runtimeconst { TaskExecutionArn } = yield* startTaskExecution();yield* Effect.log(`transfer started: ${TaskExecutionArn}`);Source:
src/AWS/DataSync/Task.ts
A DataSync task — the transfer definition binding a source location to a destination location, together with the filters, schedule, and transfer options that govern each run.
Creating the task does not move any data; it defines the transfer.
Start a run with StartTaskExecution (or attach a schedule). Source and
destination locations and the task mode are immutable; everything else
(name, options, filters, schedule, log group, tags) is updated in place.
Task: Creating Tasks
Section titled “Task: Creating Tasks”S3 → S3 transfer
import * as AWS from "alchemy/AWS";
const task = yield* AWS.DataSync.Task("Backup", { sourceLocationArn: source.locationArn, destinationLocationArn: dest.locationArn,});With verification and a schedule
const task = yield* AWS.DataSync.Task("Nightly", { sourceLocationArn: source.locationArn, destinationLocationArn: dest.locationArn, options: { VerifyMode: "ONLY_FILES_TRANSFERRED" }, schedule: { ScheduleExpression: "cron(0 2 * * ? *)" },});UpdateTaskExecution
Section titled “UpdateTaskExecution”Source:
src/AWS/DataSync/UpdateTaskExecution.ts
Runtime binding for datasync:UpdateTaskExecution.
Modifies an in-flight execution of the bound Task. The only
mutable option is BytesPerSecond — throttle (or unthrottle with -1) a
running transfer without cancelling it. The execution must be launching,
preparing, transferring, or verifying. Address it with the ARN returned
by StartTaskExecution; access is granted on the bound task’s
executions. Provide the implementation with
Effect.provide(AWS.DataSync.UpdateTaskExecutionHttp).
UpdateTaskExecution: Running Transfers
Section titled “UpdateTaskExecution: Running Transfers”// init — bind the operation to the taskconst updateTaskExecution = yield* AWS.DataSync.UpdateTaskExecution(task);
// runtime — cap the transfer at 1 MiB/syield* updateTaskExecution({ TaskExecutionArn: executionArn, Options: { BytesPerSecond: 1024 * 1024 },});