Skip to content

AWS.DataSync reference

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).

// init — bind the operation to the task
const cancelTaskExecution = yield* AWS.DataSync.CancelTaskExecution(task);
// runtime
yield* cancelTaskExecution({ TaskExecutionArn: executionArn });

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).

// init — bind the operation to the task
const describeTask = yield* AWS.DataSync.DescribeTask(task);
// runtime
const detail = yield* describeTask();
yield* Effect.log(`task ${detail.Name} is ${detail.Status}`);

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).

// init — bind the operation to the task
const describeTaskExecution = yield* AWS.DataSync.DescribeTaskExecution(task);
// runtime
const execution = yield* describeTaskExecution({
TaskExecutionArn: executionArn,
});
yield* Effect.log(`${execution.Status}: ${execution.BytesTransferred} bytes`);

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).

// init — bind the operation to the task
const listTaskExecutions = yield* AWS.DataSync.ListTaskExecutions(task);
// runtime
const { TaskExecutions } = yield* listTaskExecutions();
for (const execution of TaskExecutions ?? []) {
yield* Effect.log(`${execution.TaskExecutionArn}: ${execution.Status}`);
}

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.

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}`,
],
});
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 * * ? *)" },
});

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.

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",
});

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).

// init — bind the operation to the task
const startTaskExecution = yield* AWS.DataSync.StartTaskExecution(task);
// runtime
const { 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.

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 * * ? *)" },
});

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).

// init — bind the operation to the task
const updateTaskExecution = yield* AWS.DataSync.UpdateTaskExecution(task);
// runtime — cap the transfer at 1 MiB/s
yield* updateTaskExecution({
TaskExecutionArn: executionArn,
Options: { BytesPerSecond: 1024 * 1024 },
});