Function: AWS EC2 Volume Create

by Simon Sparks · 7 February 2026

To use this function add it to the class library file named OrchestratorPluginAWSService.ts

GitHub Repository: https://github.com/SimonSparksUK/Orchestrator

Filename: OrchestratorPluginAWSService.ts

Description: Orchestrator Function to Create an AWS EC2 Volume

Public Function: EC2VolumeCreate

public EC2VolumeCreate(objAWSClient: AWSClient, strAvailabilityZone: string, intIops: number, intSize: number, intThroughput: number, strVolumeType: "standard" | "io1" | "io2" | "gp2" | "sc1" | "st1" | "gp3" = "gp2", blnMultiAttachEnabled: boolean = false): EC2Volume {

    // IOPS
    // gp3: 3,000(default ) - 80,000 IOPS
    // io1: 100 - 64,000 IOPS
    // io2: 100 - 256,000 IOPS

    // SIZE
    // gp2: 1 - 16, 384 GiB
    // gp3: 1 - 65, 536 GiB
    // io1: 4 - 16, 384 GiB
    // io2: 4 - 65, 536 GiB
    // st1 and sc1: 125 - 16, 384 GiB
    // standard: 1 - 1024 GiB

    // THROUGHPUT - Valid Range: 125 - 2000 MiB/s

    // VOLUME TYPE
    // General Purpose SSD: gp2 | gp3
    // Provisioned IOPS SSD: io1 | io2
    // Throughput Optimized HDD: st1 - can't be used as boot volume
    // Cold HDD: sc1 - can't be used as boot volume
    // Magnetic: standard

    let objAmazonEC2Client: AmazonEC2Client = objAWSClient.getAmazonEC2Client();

    let objEC2CreateVolumeRequest: EC2CreateVolumeRequest = new EC2CreateVolumeRequest();
    objEC2CreateVolumeRequest.setAvailabilityZone(strAvailabilityZone);
    objEC2CreateVolumeRequest.setIops(intIops);
    objEC2CreateVolumeRequest.setMultiAttachEnabled(blnMultiAttachEnabled)
    objEC2CreateVolumeRequest.setSize(intSize);
    objEC2CreateVolumeRequest.setThroughput(intThroughput);
    objEC2CreateVolumeRequest.setVolumeType(strVolumeType);

    let objEC2CreateVolumeResult: EC2CreateVolumeResult = objAmazonEC2Client.createVolume(objEC2CreateVolumeRequest);

    let objEC2Volume: EC2Volume = objEC2CreateVolumeResult.getVolume();

    return objEC2Volume;
}

Discover more from Cloud Build Tools

Subscribe to get the latest posts sent to your email.

You may also like