Search in sources :

Example 1 with DeleteKeyPairResult

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

the class DeleteKeyPair method main.

public static void main(String[] args) {
    final String USAGE = "To run this example, supply a key pair name\n" + "Ex: DeleteKeyPair <key-pair-name>\n";
    if (args.length != 1) {
        System.out.println(USAGE);
        System.exit(1);
    }
    String key_name = args[0];
    final AmazonEC2 ec2 = AmazonEC2ClientBuilder.defaultClient();
    DeleteKeyPairRequest request = new DeleteKeyPairRequest().withKeyName(key_name);
    DeleteKeyPairResult response = ec2.deleteKeyPair(request);
    System.out.printf("Successfully deleted key pair named %s", key_name);
}
Also used : DeleteKeyPairResult(com.amazonaws.services.ec2.model.DeleteKeyPairResult) AmazonEC2(com.amazonaws.services.ec2.AmazonEC2) DeleteKeyPairRequest(com.amazonaws.services.ec2.model.DeleteKeyPairRequest)

Aggregations

AmazonEC2 (com.amazonaws.services.ec2.AmazonEC2)1 DeleteKeyPairRequest (com.amazonaws.services.ec2.model.DeleteKeyPairRequest)1 DeleteKeyPairResult (com.amazonaws.services.ec2.model.DeleteKeyPairResult)1