Skip to content

AWS.BackupExternal reference

Source: packages/aws/src/BackupExternal/Appliance.ts

An AWS Backup appliance — backup software that runs on your own hardware, or on EC2, and protects the workloads AWS Backup cannot reach directly: VMware virtual machines, SQL Server and Oracle databases, file servers and NAS shares.

Declaring an appliance registers it with AWS Backup and returns what its image needs to activate: image to deploy and activationToken to enter on first boot. Until a node activates, the appliance is PENDING.

A VMware appliance

import * as AWS from "@alchemy.run/aws";
const role = yield* AWS.IAM.Role("ApplianceRole", {
assumeRolePolicyDocument: {
Version: "2012-10-17",
Statement: [
{
Effect: "Allow",
Principal: { Service: "backup-external.amazonaws.com" },
Action: ["sts:AssumeRole", "sts:TagSession"],
},
],
},
managedPolicyArns: [
"arn:aws:iam::aws:policy/service-role/AWSBackupServiceRolePolicyForBackupAppliance",
],
});
const appliance = yield* AWS.BackupExternal.Appliance("Datacenter", {
environmentType: "VMWARE",
applianceIamRoleArn: role.roleArn,
nodeFaultTolerance: 1,
networkConfiguration: {
subnetGateway: "10.0.0.1",
subnetMask: "255.255.255.0",
dnsServers: ["10.0.0.2"],
ntpServers: ["time.aws.com"],
},
});

Read what the appliance image needs to activate

return {
image: appliance.image,
activationToken: appliance.activationToken,
expiresAt: appliance.activationTokenExpiresAt,
};
const appliance = yield* AWS.BackupExternal.Appliance("Datacenter", {
environmentType: "VMWARE",
applianceIamRoleArn: role.roleArn,
nodeFaultTolerance: 1,
networkConfiguration,
agentAutoUpgrade: { startHourUtc: 22, endHourUtc: 4 },
});
const appliance = yield* AWS.BackupExternal.Appliance("Datacenter", {
environmentType: "VMWARE",
applianceIamRoleArn: role.roleArn,
nodeFaultTolerance: 1,
networkConfiguration,
operationMode: "PAUSED",
});

Appliance: Looking up an existing appliance

Section titled “Appliance: Looking up an existing appliance”

Appliance.lookup references an appliance Alchemy doesn’t manage (created in the console or by another stack), found by applianceArn or applianceName. It is read during plan/deploy and never created, updated or deleted.

const appliance = AWS.BackupExternal.Appliance.lookup({ applianceName: "datacenter" });

Source: packages/aws/src/BackupExternal/AssociateDisk.ts

Runtime binding for the AssociateDisk operation (IAM action backup-external:AssociateDisk).

Gives a disk attached to a node of the bound Appliance to the appliance, as data or metadata storage. Provide the implementation with Effect.provide(AWS.BackupExternal.AssociateDiskHttp).

const associateDisk = yield* AWS.BackupExternal.AssociateDisk(appliance);
yield* associateDisk({
NodeArn: nodeArn,
DiskIdentifier: disk.DiskIdentifier,
DiskType: "DATA",
});

Source: packages/aws/src/BackupExternal/DeleteResourceTarget.ts

Runtime binding for the DeleteResourceTarget operation (IAM action backup-external:DeleteResourceTarget).

Deletes a resource target, for example one its source no longer reports. Resource targets are discovered at run time, so the grant covers every resource target in the account. Provide the implementation with Effect.provide(AWS.BackupExternal.DeleteResourceTargetHttp).

const deleteResourceTarget = yield* AWS.BackupExternal.DeleteResourceTarget();
yield* deleteResourceTarget({ Arn: targetArn });

Source: packages/aws/src/BackupExternal/GetActivationCredentials.ts

Runtime binding for the GetActivationCredentials operation (IAM action backup-external:GetActivationCredentials).

Returns a fresh activation token for the bound Appliance, with the image to deploy it from. Activation tokens expire, so automation that boots an appliance image reads one just before it is needed. Provide the implementation with Effect.provide(AWS.BackupExternal.GetActivationCredentialsHttp).

GetActivationCredentials: Activating an Appliance

Section titled “GetActivationCredentials: Activating an Appliance”
const getActivationCredentials =
yield* AWS.BackupExternal.GetActivationCredentials(appliance);
const { ActivationToken, ActivationTokenExpiresAt } = yield* getActivationCredentials();

Source: packages/aws/src/BackupExternal/GetAgentDownload.ts

Runtime binding for the GetAgentDownload operation (IAM action backup-external:GetAgentDownload).

Returns the download URL and version of the agent installer that connects a server to the bound Appliance, for one platform. Provide the implementation with Effect.provide(AWS.BackupExternal.GetAgentDownloadHttp).

const getAgentDownload = yield* AWS.BackupExternal.GetAgentDownload(appliance);
const { AgentDownloadUrl, AgentVersion } = yield* getAgentDownload({
Platform: "LINUX_RPM",
});

Source: packages/aws/src/BackupExternal/GetAppliance.ts

Runtime binding for the GetAppliance operation (IAM action backup-external:GetAppliance).

Returns the configuration and status of the bound Appliance: management status, operation mode, health and software version. Provide the implementation with Effect.provide(AWS.BackupExternal.GetApplianceHttp).

const getAppliance = yield* AWS.BackupExternal.GetAppliance(appliance);
const { HealthStatus, ApplianceOperationMode } = yield* getAppliance();

Source: packages/aws/src/BackupExternal/GetApplianceSizingRecommendation.ts

Runtime binding for the GetApplianceSizingRecommendation operation (IAM action backup-external:GetApplianceSizingRecommendation).

Calculates how many appliance nodes, and how much data and metadata storage per node, a set of workloads needs over a projection period. It reads no appliance: it is a calculation over the workloads you describe. Provide the implementation with Effect.provide(AWS.BackupExternal.GetApplianceSizingRecommendationHttp).

GetApplianceSizingRecommendation: Sizing an Appliance

Section titled “GetApplianceSizingRecommendation: Sizing an Appliance”
const getSizing = yield* AWS.BackupExternal.GetApplianceSizingRecommendation();
const { Projections } = yield* getSizing({
NodeType: "VMWARE",
ProjectionYears: 3,
Workloads: [
{
InitialSizeTiB: 10,
ChangeRatePercent: 2,
AnnualGrowthRatePercent: 10,
BackupConfiguration: {
VmwareVm: {
BackupRules: [{ Frequency: 1, FrequencyUnit: "DAYS", DeleteAfterDays: 30 }],
},
},
},
],
});

Source: packages/aws/src/BackupExternal/GetNode.ts

Runtime binding for the GetNode operation (IAM action backup-external:GetNode).

Returns one node of the bound Appliance: its IP address, status, health and software version. Provide the implementation with Effect.provide(AWS.BackupExternal.GetNodeHttp).

const getNode = yield* AWS.BackupExternal.GetNode(appliance);
const node = yield* getNode({ NodeArn: nodeArn });
yield* Effect.log(`${node.IpAddress}: ${node.HealthStatus}`);

Source: packages/aws/src/BackupExternal/GetResourceProvider.ts

Runtime binding for the GetResourceProvider operation (IAM action backup-external:GetResourceProvider).

Returns the configuration, metadata and status of the bound ResourceProvider, including when it last synced and whether its agent is up to date. Provide the implementation with Effect.provide(AWS.BackupExternal.GetResourceProviderHttp).

const getResourceProvider = yield* AWS.BackupExternal.GetResourceProvider(vcenter);
const { Status, LastSyncCompletedAt } = yield* getResourceProvider();

Source: packages/aws/src/BackupExternal/GetResourceTarget.ts

Runtime binding for the GetResourceTarget operation (IAM action backup-external:GetResourceTarget).

Returns the configuration, metadata and status of one resource target. Resource targets are discovered at run time, so the grant covers every resource target in the account. Provide the implementation with Effect.provide(AWS.BackupExternal.GetResourceTargetHttp).

const getResourceTarget = yield* AWS.BackupExternal.GetResourceTarget();
const target = yield* getResourceTarget({ Arn: targetArn });
yield* Effect.log(`${target.ExternalName}: ${target.Status}`);

Source: packages/aws/src/BackupExternal/ListAppliances.ts

Runtime binding for the ListAppliances operation (IAM action backup-external:ListAppliances).

Lists the backup appliances registered in the account and Region, with their management status, operation mode and health. Provide the implementation with Effect.provide(AWS.BackupExternal.ListAppliancesHttp).

const listAppliances = yield* AWS.BackupExternal.ListAppliances();
const { Appliances } = yield* listAppliances();
const unhealthy = Appliances.filter((a) => a.HealthStatus === "CRITICAL");

Source: packages/aws/src/BackupExternal/ListDisks.ts

Runtime binding for the ListDisks operation (IAM action backup-external:ListDisks).

Lists the disks attached to one node of the bound Appliance, and whether each is already associated as data or metadata storage. Provide the implementation with Effect.provide(AWS.BackupExternal.ListDisksHttp).

const listDisks = yield* AWS.BackupExternal.ListDisks(appliance);
const { Disks } = yield* listDisks({ NodeArn: nodeArn });
const free = Disks.filter((disk) => disk.Status === "AVAILABLE");

Source: packages/aws/src/BackupExternal/ListNodes.ts

Runtime binding for the ListNodes operation (IAM action backup-external:ListNodes).

Lists the nodes of the bound Appliance with their management and health status. Provide the implementation with Effect.provide(AWS.BackupExternal.ListNodesHttp).

const listNodes = yield* AWS.BackupExternal.ListNodes(appliance);
const { Nodes } = yield* listNodes();
const pending = Nodes.filter((n) => n.NodeManagementStatus === "PENDING_VERIFICATION");

Source: packages/aws/src/BackupExternal/ListResourceProviders.ts

Runtime binding for the ListResourceProviders operation (IAM action backup-external:ListResourceProviders).

Lists the resource providers in the account and Region, optionally only those of one appliance or one provider type. Provide the implementation with Effect.provide(AWS.BackupExternal.ListResourceProvidersHttp).

const listResourceProviders = yield* AWS.BackupExternal.ListResourceProviders();
const { Items } = yield* listResourceProviders({
ResourceProviderType: "VMWARE_VCENTER",
});

Source: packages/aws/src/BackupExternal/ListResourceTargets.ts

Runtime binding for the ListResourceTargets operation (IAM action backup-external:ListResourceTargets).

Lists the resource targets (the virtual machines, databases and filesystems that resource providers discovered), optionally only those of one resource provider or one target type. Provide the implementation with Effect.provide(AWS.BackupExternal.ListResourceTargetsHttp).

const listResourceTargets = yield* AWS.BackupExternal.ListResourceTargets();
const { Items } = yield* listResourceTargets({ ResourceTargetType: "VMWARE_VM" });
const missing = Items.filter((target) => target.Status === "NOT_FOUND");

Source: packages/aws/src/BackupExternal/ResourceProvider.ts

An AWS Backup resource provider — one source a backup appliance protects: a VMware vCenter Server or ESXi host, a SQL Server or Oracle database server, a file server, or a NAS share.

The appliance connects to the source and discovers what it holds (virtual machines, databases, filesystems) as resource targets, each of which a backup plan can then select. A resource provider needs an appliance that has been activated.

A VMware vCenter Server

import * as AWS from "@alchemy.run/aws";
const vcenter = yield* AWS.BackupExternal.ResourceProvider("Vcenter", {
applianceArn: appliance.applianceArn,
source: { vmwareVcenter: { endpoint: "vcenter.corp.example.com" } },
secretConfigurationArn: credentials.secretArn,
targetDefaults: {
vmwareVm: { backupConsistency: "APP_CONSISTENT_FALLBACK_TO_CRASH_CONSISTENT" },
},
});

A NAS share

const share = yield* AWS.BackupExternal.ResourceProvider("Share", {
applianceArn: appliance.applianceArn,
source: { nasShare: { sharePath: "10.0.0.5:/exports/home", protocol: "NFS_4_1" } },
targetDefaults: { nasFilesystem: { allowUnencryptedDataTransfer: false } },
});

A SQL Server with log backups

const sql = yield* AWS.BackupExternal.ResourceProvider("Sql", {
applianceArn: appliance.applianceArn,
source: { mssqlServer: { endpoint: "sql01.corp.example.com" } },
secretConfigurationArn: credentials.secretArn,
targetDefaults: {
mssqlDatabase: {
fullBackupAfterDays: 7,
isCopyOnlyFull: false,
logBackupFrequencyInMinutes: 15,
},
},
});
const vcenter = yield* AWS.BackupExternal.ResourceProvider("Vcenter", {
applianceArn: appliance.applianceArn,
source: { vmwareVcenter: { endpoint: "vcenter.corp.example.com" } },
targetDefaults: { vmwareVm: {} },
targetTagsOnCreate: { backup: "daily" },
targetTagKeysToSync: ["owner"],
autoDeleteNotFoundTargetsAfterDays: 30,
});

ResourceProvider: Looking up an existing resource provider

Section titled “ResourceProvider: Looking up an existing resource provider”

ResourceProvider.lookup references a resource provider Alchemy doesn’t manage (created in the console or by another stack), found by resourceProviderArn. It is read during plan/deploy and never created, updated or deleted.

const vcenter = AWS.BackupExternal.ResourceProvider.lookup({ resourceProviderArn });

Source: packages/aws/src/BackupExternal/StartResourceProviderAgentUpgrade.ts

Runtime binding for the StartResourceProviderAgentUpgrade operation (IAM action backup-external:StartResourceProviderAgentUpgrade).

Starts an upgrade of the agent of the bound ResourceProvider. Provide the implementation with Effect.provide(AWS.BackupExternal.StartResourceProviderAgentUpgradeHttp).

const startAgentUpgrade =
yield* AWS.BackupExternal.StartResourceProviderAgentUpgrade(sqlServer);
const { UpgradeStartedAt } = yield* startAgentUpgrade();

Source: packages/aws/src/BackupExternal/StartResourceProviderSync.ts

Runtime binding for the StartResourceProviderSync operation (IAM action backup-external:StartResourceProviderSync).

Starts a sync of the bound ResourceProvider: the appliance asks the source what it holds and updates the provider’s resource targets. Provide the implementation with Effect.provide(AWS.BackupExternal.StartResourceProviderSyncHttp).

StartResourceProviderSync: Resource Providers

Section titled “StartResourceProviderSync: Resource Providers”
const startSync = yield* AWS.BackupExternal.StartResourceProviderSync(vcenter);
const { SyncStartedAt } = yield* startSync();

Source: packages/aws/src/BackupExternal/UpdateResourceTarget.ts

Runtime binding for the UpdateResourceTarget operation (IAM action backup-external:UpdateResourceTarget).

Renames a resource target or overrides the backup configuration it inherits from its resource provider. Resource targets are discovered at run time, so the grant covers every resource target in the account. Provide the implementation with Effect.provide(AWS.BackupExternal.UpdateResourceTargetHttp).

const updateResourceTarget = yield* AWS.BackupExternal.UpdateResourceTarget();
yield* updateResourceTarget({
Arn: targetArn,
TargetConfigurationSource: "TARGET",
TargetConfiguration: { VmwareVm: { BackupConsistency: "CRASH_CONSISTENT" } },
});

Source: packages/aws/src/BackupExternal/VerifyNodes.ts

Runtime binding for the VerifyNodes operation (IAM action backup-external:VerifyNodes).

Verifies nodes of the bound Appliance that are PENDING_VERIFICATION, so they can join the appliance. Provide the implementation with Effect.provide(AWS.BackupExternal.VerifyNodesHttp).

const listNodes = yield* AWS.BackupExternal.ListNodes(appliance);
const verifyNodes = yield* AWS.BackupExternal.VerifyNodes(appliance);
const { Nodes } = yield* listNodes();
yield* verifyNodes({
NodeArns: Nodes.filter((n) => n.NodeManagementStatus === "PENDING_VERIFICATION").map(
(n) => n.NodeArn,
),
});