Example usage for com.amazonaws.services.ec2 AmazonEC2 importKeyPair

List of usage examples for com.amazonaws.services.ec2 AmazonEC2 importKeyPair

Introduction

In this page you can find the example usage for com.amazonaws.services.ec2 AmazonEC2 importKeyPair.

Prototype

ImportKeyPairResult importKeyPair(ImportKeyPairRequest importKeyPairRequest);

Source Link

Document

Imports the public key from an RSA key pair that you created with a third-party tool.

Usage

From source file:com.axemblr.provisionr.amazon.activities.EnsureKeyPairExists.java

License:Apache License

private void importPoolPublicKeyPair(AmazonEC2 client, String keyName, String publicKey) {
    ImportKeyPairResult result = client
            .importKeyPair(new ImportKeyPairRequest().withKeyName(keyName).withPublicKeyMaterial(publicKey));
    LOG.info("<< Created remote key with fingerprint {}", result.getKeyFingerprint());
}

From source file:edu.umass.cs.aws.support.AWSEC2.java

License:Apache License

/**
 *
 * @param ec2//from  www .  j  a  v  a  2s  .c  o  m
 * @param name
 * @param publicKeyMaterial
 */
public static void importKeyPair(AmazonEC2 ec2, String name, String publicKeyMaterial) {
    ImportKeyPairRequest newKeyRequest = new ImportKeyPairRequest(name, publicKeyMaterial);
    ec2.importKeyPair(newKeyRequest);
}

From source file:jp.classmethod.aws.gradle.ec2.AmazonEC2ImportKeyTask.java

License:Apache License

@TaskAction
public void importKey() {
    // to enable conventionMappings feature
    String keyName = getKeyName();
    String publicKeyMaterial = getPublicKeyMaterial();

    if (keyName == null) {
        throw new GradleException("keyName is required");
    }//from   w w  w.  jav a  2  s .c om

    AmazonEC2PluginExtension ext = getProject().getExtensions().getByType(AmazonEC2PluginExtension.class);
    AmazonEC2 ec2 = ext.getClient();

    if (isIfNotExists() == false || exists(ec2) == false) {
        importKeyPairResult = ec2.importKeyPair(new ImportKeyPairRequest(keyName, publicKeyMaterial));
        getLogger().info("KeyPair imported: {}", importKeyPairResult.getKeyFingerprint());
    }
}

From source file:org.xmlsh.aws.gradle.ec2.AmazonEC2ImportKeyTask.java

License:BSD License

@TaskAction
public void importKey() {
    // to enable conventionMappings feature
    String keyName = getKeyName();
    String publicKeyMaterial = getPublicKeyMaterial();

    if (keyName == null)
        throw new GradleException("keyName is required");

    AmazonEC2PluginExtension ext = getProject().getExtensions().getByType(AmazonEC2PluginExtension.class);
    AmazonEC2 ec2 = ext.getClient();

    if (isIfNotExists() == false || exists(ec2) == false) {
        importKeyPairResult = ec2.importKeyPair(new ImportKeyPairRequest(keyName, publicKeyMaterial));
        getLogger().info("KeyPair imported: {}", importKeyPairResult.getKeyFingerprint());
    }//from w ww .  java 2s. c  o  m
}