Search in sources :

Example 1 with DeleteKeyPairResponse

use of software.amazon.awssdk.services.ec2.model.DeleteKeyPairResponse 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

DeleteKeyPairRequest (software.amazon.awssdk.services.ec2.model.DeleteKeyPairRequest)1 DeleteKeyPairResponse (software.amazon.awssdk.services.ec2.model.DeleteKeyPairResponse)1 Ec2Exception (software.amazon.awssdk.services.ec2.model.Ec2Exception)1