Skip to content
GitHubXDiscordRSS

Agent

Learn how to create, update, and manage AWS DataSync Agents using Alchemy Cloud Control.

The Agent resource lets you manage AWS DataSync Agents for transferring data between on-premises storage and AWS storage services.

Create a basic DataSync Agent with a specified subnet and security group:

import AWS from "alchemy/aws/control";
const dataSyncAgent = await AWS.DataSync.Agent("myDataSyncAgent", {
SubnetArns: [
"arn:aws:ec2:us-west-2:123456789012:subnet/subnet-0abcd1234efgh5678"
],
SecurityGroupArns: [
"arn:aws:ec2:us-west-2:123456789012:security-group/sg-0abcd1234efgh5678"
],
AgentName: "MyDataSyncAgent"
});

Configure an Agent with a VPC endpoint and tags for better management and organization:

const advancedDataSyncAgent = await AWS.DataSync.Agent("advancedDataSyncAgent", {
SubnetArns: [
"arn:aws:ec2:us-west-2:123456789012:subnet/subnet-0abcd1234efgh5678"
],
SecurityGroupArns: [
"arn:aws:ec2:us-west-2:123456789012:security-group/sg-0abcd1234efgh5678"
],
VpcEndpointId: "vpce-0abcd1234efgh5678",
Tags: [
{ Key: "Environment", Value: "Production" },
{ Key: "Project", Value: "DataSyncMigration" }
]
});

If an existing DataSync Agent is present, you can adopt it instead of failing:

const adoptedDataSyncAgent = await AWS.DataSync.Agent("adoptedDataSyncAgent", {
SubnetArns: [
"arn:aws:ec2:us-west-2:123456789012:subnet/subnet-0abcd1234efgh5678"
],
SecurityGroupArns: [
"arn:aws:ec2:us-west-2:123456789012:security-group/sg-0abcd1234efgh5678"
],
adopt: true // Allow adoption of existing resources
});

Create a DataSync Agent with an activation key for secure configuration:

const activatedDataSyncAgent = await AWS.DataSync.Agent("activatedDataSyncAgent", {
SubnetArns: [
"arn:aws:ec2:us-west-2:123456789012:subnet/subnet-0abcd1234efgh5678"
],
SecurityGroupArns: [
"arn:aws:ec2:us-west-2:123456789012:security-group/sg-0abcd1234efgh5678"
],
ActivationKey: "my-activation-key-12345"
});