Search in sources :

Example 16 with Ec2Exception

use of software.amazon.awssdk.services.ec2.model.Ec2Exception in project aws-doc-sdk-examples by awsdocs.

the class DeleteKeyPair method deleteKeys.

// snippet-start:[ec2.java2.delete_key_pair.main]
public static void deleteKeys(Ec2Client ec2, String keyPair) {
    try {
        DeleteKeyPairRequest request = DeleteKeyPairRequest.builder().keyName(keyPair).build();
        DeleteKeyPairResponse response = ec2.deleteKeyPair(request);
        System.out.printf("Successfully deleted key pair named %s", keyPair);
    } catch (Ec2Exception e) {
        System.err.println(e.awsErrorDetails().errorMessage());
        System.exit(1);
    }
}
Also used : DeleteKeyPairResponse(software.amazon.awssdk.services.ec2.model.DeleteKeyPairResponse) Ec2Exception(software.amazon.awssdk.services.ec2.model.Ec2Exception) DeleteKeyPairRequest(software.amazon.awssdk.services.ec2.model.DeleteKeyPairRequest)

Aggregations

Ec2Exception (software.amazon.awssdk.services.ec2.model.Ec2Exception)16 DescribeInstancesRequest (software.amazon.awssdk.services.ec2.model.DescribeInstancesRequest)2 DescribeInstancesResponse (software.amazon.awssdk.services.ec2.model.DescribeInstancesResponse)2 Instance (software.amazon.awssdk.services.ec2.model.Instance)2 Reservation (software.amazon.awssdk.services.ec2.model.Reservation)2 ListIterator (java.util.ListIterator)1 AccountAttribute (software.amazon.awssdk.services.ec2.model.AccountAttribute)1 AccountAttributeValue (software.amazon.awssdk.services.ec2.model.AccountAttributeValue)1 AllocateAddressRequest (software.amazon.awssdk.services.ec2.model.AllocateAddressRequest)1 AllocateAddressResponse (software.amazon.awssdk.services.ec2.model.AllocateAddressResponse)1 AssociateAddressRequest (software.amazon.awssdk.services.ec2.model.AssociateAddressRequest)1 AssociateAddressResponse (software.amazon.awssdk.services.ec2.model.AssociateAddressResponse)1 AuthorizeSecurityGroupIngressRequest (software.amazon.awssdk.services.ec2.model.AuthorizeSecurityGroupIngressRequest)1 AuthorizeSecurityGroupIngressResponse (software.amazon.awssdk.services.ec2.model.AuthorizeSecurityGroupIngressResponse)1 AvailabilityZone (software.amazon.awssdk.services.ec2.model.AvailabilityZone)1 CreateKeyPairRequest (software.amazon.awssdk.services.ec2.model.CreateKeyPairRequest)1 CreateSecurityGroupRequest (software.amazon.awssdk.services.ec2.model.CreateSecurityGroupRequest)1 CreateSecurityGroupResponse (software.amazon.awssdk.services.ec2.model.CreateSecurityGroupResponse)1 CreateTagsRequest (software.amazon.awssdk.services.ec2.model.CreateTagsRequest)1 DeleteKeyPairRequest (software.amazon.awssdk.services.ec2.model.DeleteKeyPairRequest)1