Example usage for com.amazonaws.services.ec2 AmazonEC2Client createKeyPair

List of usage examples for com.amazonaws.services.ec2 AmazonEC2Client createKeyPair

Introduction

In this page you can find the example usage for com.amazonaws.services.ec2 AmazonEC2Client createKeyPair.

Prototype

@Override
public CreateKeyPairResult createKeyPair(CreateKeyPairRequest request) 

Source Link

Document

Creates a 2048-bit RSA key pair with the specified name.

Usage

From source file:n3phele.factory.ec2.VirtualServerResource.java

License:Open Source License

protected boolean createKey(String key, String id, String secret, URI location, String email, String firstName,
        String lastName) {//from  w  w w  .j  a v  a 2 s . c o m
    AmazonEC2Client client = null;
    client = getEC2Client(id, secret, location);
    boolean found = true;
    try {
        CreateKeyPairResult response = client
                .createKeyPair(new CreateKeyPairRequest().withKeyName("n3phele-" + key));
        log.warning("Got " + response.getKeyPair().toString());
        sendNotificationEmail(response.getKeyPair(), email, firstName, lastName, location);
    } catch (Exception e) {
        log.severe("Create key pair exception " + e.getMessage());
        found = false;
    }
    return found;
}