Search in sources :

Example 1 with KeyPairInfo

use of com.amazonaws.services.ec2.model.KeyPairInfo in project aws-doc-sdk-examples by awsdocs.

the class DescribeKeyPairs method main.

public static void main(String[] args) {
    final AmazonEC2 ec2 = AmazonEC2ClientBuilder.defaultClient();
    DescribeKeyPairsResult response = ec2.describeKeyPairs();
    for (KeyPairInfo key_pair : response.getKeyPairs()) {
        System.out.printf("Found key pair with name %s " + "and fingerprint %s", key_pair.getKeyName(), key_pair.getKeyFingerprint());
    }
}
Also used : KeyPairInfo(com.amazonaws.services.ec2.model.KeyPairInfo) DescribeKeyPairsResult(com.amazonaws.services.ec2.model.DescribeKeyPairsResult) AmazonEC2(com.amazonaws.services.ec2.AmazonEC2)

Example 2 with KeyPairInfo

use of com.amazonaws.services.ec2.model.KeyPairInfo in project GNS by MobilityFirst.

the class AWSEC2 method describeKeyPairs.

/**
   * Describe Key Pairs
   *
   * @param ec2
   */
public static void describeKeyPairs(AmazonEC2 ec2) {
    StringBuilder output = new StringBuilder();
    String prefix = currentTab + "Key Pairs: ";
    DescribeKeyPairsResult dkr = ec2.describeKeyPairs();
    for (KeyPairInfo keyPairInfo : dkr.getKeyPairs()) {
        output.append(prefix);
        prefix = ", ";
        output.append(keyPairInfo.getKeyName());
    }
    System.out.println(output);
}
Also used : KeyPairInfo(com.amazonaws.services.ec2.model.KeyPairInfo) DescribeKeyPairsResult(com.amazonaws.services.ec2.model.DescribeKeyPairsResult)

Aggregations

DescribeKeyPairsResult (com.amazonaws.services.ec2.model.DescribeKeyPairsResult)2 KeyPairInfo (com.amazonaws.services.ec2.model.KeyPairInfo)2 AmazonEC2 (com.amazonaws.services.ec2.AmazonEC2)1