@devtion/actions
Version:
A set of actions and helpers for CLI commands
112 lines • 6.14 kB
TypeScript
import { EC2Client } from "@aws-sdk/client-ec2";
import { SSMClient } from "@aws-sdk/client-ssm";
import { DiskTypeForVM } from "src";
import { EC2Instance } from "../types";
/**
* Create a new AWS EC2 client.
* @returns <Promise<EC2Client>> - the EC2 client instance.
*/
export declare const createEC2Client: () => Promise<EC2Client>;
/**
* Create a new AWS SSM client.
* @returns <Promise<SSMClient>> - the SSM client instance.
*/
export declare const createSSMClient: () => Promise<SSMClient>;
/**
* Return the list of bootstrap commands to be executed.
* @dev the startup commands must be suitable for a shell script.
* @param bucketName <string> - the name of the AWS S3 bucket.
* @returns <Array<string>> - the list of startup commands to be executed.
*/
export declare const vmBootstrapCommand: (bucketName: string) => Array<string>;
/**
* Return the list of Node environment (and packages) installation plus artifact caching for contribution verification.
* @param zKeyPath <string> - the path to zKey artifact inside AWS S3 bucket.
* @param potPath <string> - the path to ptau artifact inside AWS S3 bucket.
* @param snsTopic <string> - the SNS topic ARN.
* @param region <string> - the AWS region.
* @returns <Array<string>> - the array of commands to be run by the EC2 instance.
*/
export declare const vmDependenciesAndCacheArtifactsCommand: (zKeyPath: string, potPath: string, snsTopic: string, region: string) => Array<string>;
/**
* Return the list of commands for contribution verification.
* @dev this method generates the verification transcript as well.
* @param bucketName <string> - the name of the AWS S3 bucket.
* @param lastZkeyStoragePath <string> - the last zKey storage path.
* @param verificationTranscriptStoragePathAndFilename <string> - the verification transcript storage path.
* @returns Array<string> - the list of commands for contribution verification.
*/
export declare const vmContributionVerificationCommand: (bucketName: string, lastZkeyStoragePath: string, verificationTranscriptStoragePathAndFilename: string) => Array<string>;
/**
* Compute the VM disk size.
* @dev the disk size is computed using the zKey size in bytes taking into consideration
* the verification task (2 * zKeySize) + ptauSize + OS/VM (~8GB).
* @param zKeySizeInBytes <number> the size of the zKey in bytes.
* @param pot <number> the amount of powers needed for the circuit (index of the PPoT file).
* @return <number> the configuration of the VM disk size in GB.
*/
export declare const computeDiskSizeForVM: (zKeySizeInBytes: number, pot: number) => number;
/**
* Creates a new EC2 instance
* @param ec2 <EC2Client> - the instance of the EC2 client.
* @param commands <Array<string>> - the list of commands to be run on the EC2 instance.
* @param instanceType <string> - the type of the EC2 VM instance.
* @param diskSize <number> - the size of the disk (volume) of the VM.
* @param diskType <DiskTypeForVM> - the type of the disk (volume) of the VM.
* @returns <Promise<P0tionEC2Instance>> the instance that was created
*/
export declare const createEC2Instance: (ec2: EC2Client, commands: string[], instanceType: string, volumeSize: number, diskType: DiskTypeForVM) => Promise<EC2Instance>;
/**
* Check if the current VM EC2 instance is running by querying the status.
* @param ec2 <EC2Client> - the instance of the EC2 client.
* @param instanceId <string> - the unique identifier of the EC2 VM instance.
* @returns <Promise<boolean>> - true if the current status of the EC2 VM instance is 'running'; otherwise false.
*/
export declare const checkIfRunning: (ec2Client: EC2Client, instanceId: string) => Promise<boolean>;
/**
* Start an EC2 VM instance.
* @dev the instance must have been created previously.
* @param ec2 <EC2Client> - the instance of the EC2 client.
* @param instanceId <string> - the unique identifier of the EC2 VM instance.
*/
export declare const startEC2Instance: (ec2: EC2Client, instanceId: string) => Promise<void>;
/**
* Stop an EC2 VM instance.
* @dev the instance must have been in a running status.
* @param ec2 <EC2Client> - the instance of the EC2 client.
* @param instanceId <string> - the unique identifier of the EC2 VM instance.
*/
export declare const stopEC2Instance: (ec2: EC2Client, instanceId: string) => Promise<void>;
/**
* Terminate an EC2 VM instance.
* @param ec2 <EC2Client> - the instance of the EC2 client.
* @param instanceId <string> - the unique identifier of the EC2 VM instance.
*/
export declare const terminateEC2Instance: (ec2: EC2Client, instanceId: string) => Promise<void>;
/**
* Run a command on an EC2 VM instance by using SSM.
* @dev this method returns the command identifier for checking the status and retrieve
* the output of the command execution later on.
* @param ssm <SSMClient> - the instance of the sSM client.
* @param instanceId <string> - the unique identifier of the EC2 VM instance.
* @param commands <Array<string>> - the list of commands.
* @return <Promise<string>> - the unique identifier of the command.
*/
export declare const runCommandUsingSSM: (ssm: SSMClient, instanceId: string, commands: Array<string>) => Promise<string>;
/**
* Get the output of an SSM command executed on an EC2 VM instance.
* @param ssm <SSMClient> - the instance of the sSM client.
* @param instanceId <string> - the unique identifier of the EC2 VM instance.
* @param commandId <string> - the unique identifier of the command.
* @return <Promise<string>> - the command output.
*/
export declare const retrieveCommandOutput: (ssm: SSMClient, instanceId: string, commandId: string) => Promise<string>;
/**
* Get the status of an SSM command executed on an EC2 VM instance.
* @param ssm <SSMClient> - the instance of the sSM client.
* @param instanceId <string> - the unique identifier of the EC2 VM instance.
* @param commandId <string> - the unique identifier of the command.
* @return <Promise<string>> - the command status.
*/
export declare const retrieveCommandStatus: (ssm: SSMClient, instanceId: string, commandId: string) => Promise<string>;
//# sourceMappingURL=vm.d.ts.map