List of usage examples for com.amazonaws.services.ec2 AmazonEC2 deleteKeyPair
DeleteKeyPairResult deleteKeyPair(DeleteKeyPairRequest deleteKeyPairRequest);
Deletes the specified key pair, by removing the public key from Amazon EC2.
From source file:aws.example.ec2.DeleteKeyPair.java
License:Open Source License
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);//w w w. j a v a 2 s .c om } 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); }
From source file:com.axemblr.provisionr.amazon.activities.DeleteKeyPair.java
License:Apache License
@Override public void execute(AmazonEC2 client, Pool pool, DelegateExecution execution) { String keyName = KeyPairs.formatNameFromBusinessKey(execution.getProcessBusinessKey()); LOG.info(">> Deleting key pair {}", keyName); client.deleteKeyPair(new DeleteKeyPairRequest().withKeyName(keyName)); }
From source file:com.axemblr.provisionr.amazon.activities.EnsureKeyPairExists.java
License:Apache License
@Override public void execute(AmazonEC2 client, Pool pool, DelegateExecution execution) { String keyName = KeyPairs.formatNameFromBusinessKey(execution.getProcessBusinessKey()); LOG.info(">> Importing admin access key pair as {}", keyName); final String publicKey = pool.getAdminAccess().getPublicKey(); try {/* w w w. ja v a 2 s . c o m*/ importPoolPublicKeyPair(client, keyName, publicKey); } catch (AmazonServiceException e) { if (e.getErrorCode().equals(ErrorCodes.DUPLICATE_KEYPAIR)) { LOG.info("<< Duplicate key pair found. Re-importing from pool description"); client.deleteKeyPair(new DeleteKeyPairRequest().withKeyName(keyName)); importPoolPublicKeyPair(client, keyName, publicKey); } } }
From source file:ec2.DeleteKeyPair.java
License:Open Source License
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);/*from w w w .j ava 2 s . c o m*/ } String keyPairName = args[0]; final AmazonEC2 ec2 = AmazonEC2ClientBuilder.defaultClient(); DeleteKeyPairRequest request = new DeleteKeyPairRequest().withKeyName(keyPairName); DeleteKeyPairResult response = ec2.deleteKeyPair(request); System.out.printf("Successfully deleted key pair named %s", keyPairName); }