Function: AWS EC2 Key Pair 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 Key Pair

Public Function: EC2KeyPairInfoCreate

public EC2KeyPairGet(objAWSClient: AWSClient, strKeyFormat: "pem" | "ppk", strKeyName: string, strKeyType: "rsa" | "ed25519"): EC2KeyPair {

    let objAmazonEC2Client: AmazonEC2Client = objAWSClient.getAmazonEC2Client();

    let objEC2CreateKeyPairRequest: EC2CreateKeyPairRequest = new EC2CreateKeyPairRequest();
    objEC2CreateKeyPairRequest.setKeyFormat(strKeyFormat);
    objEC2CreateKeyPairRequest.setKeyName(strKeyName);
    objEC2CreateKeyPairRequest.setKeyType(strKeyType);

    let objEC2CreateKeyPairResult: EC2CreateKeyPairResult = objAmazonEC2Client.createKeyPair(objEC2CreateKeyPairRequest);

    let objEC2KeyPair: EC2KeyPair = objEC2CreateKeyPairResult.getKeyPair();

    return objEC2KeyPair;
}

Discover more from Cloud Build Tools

Subscribe to get the latest posts sent to your email.

You may also like