Search in sources :

Example 66 with AmazonEC2

use of com.amazonaws.services.ec2.AmazonEC2 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)42 Instance (com.amazonaws.services.ec2.model.Instance)12 AmazonEC2Client (com.amazonaws.services.ec2.AmazonEC2Client)9 AWSCredentials (com.amazonaws.auth.AWSCredentials)5 PropertiesCredentials (com.amazonaws.auth.PropertiesCredentials)5 Address (com.amazonaws.services.ec2.model.Address)5 InstanceInfo (com.netflix.appinfo.InstanceInfo)5 File (java.io.File)5 LinkedList (java.util.LinkedList)5 DescribeAddressesResult (com.amazonaws.services.ec2.model.DescribeAddressesResult)4 DescribeInstancesResult (com.amazonaws.services.ec2.model.DescribeInstancesResult)4 DryRunResult (com.amazonaws.services.ec2.model.DryRunResult)4 Reservation (com.amazonaws.services.ec2.model.Reservation)4 SecurityGroup (com.amazonaws.services.ec2.model.SecurityGroup)4 Tag (com.amazonaws.services.ec2.model.Tag)4 AmazonInfo (com.netflix.appinfo.AmazonInfo)4 AssociateAddressRequest (com.amazonaws.services.ec2.model.AssociateAddressRequest)3 AvailabilityZone (com.amazonaws.services.ec2.model.AvailabilityZone)3 CreateTagsRequest (com.amazonaws.services.ec2.model.CreateTagsRequest)3 DescribeAvailabilityZonesResult (com.amazonaws.services.ec2.model.DescribeAvailabilityZonesResult)3