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);
}
}
Aggregations