public static void DeleteKeyPair(AmazonEC2Client ec2Client)
        {
            var keyName = Args.Value("KeyName");

            ec2Client.DeleteKeyPair(new DeleteKeyPairRequest {
                KeyName = keyName
            });
        }
Exemple #2
0
 public static void DeleteKeyPair(AmazonEC2Client ec2Client, KeyPair keyPair)
 {
     try
     {
         // Delete key pair created for sample.
         ec2Client.DeleteKeyPair(new DeleteKeyPairRequest {
             KeyName = keyPair.KeyName
         });
     }
     catch (AmazonEC2Exception ex)
     {
         // Check the ErrorCode to see if the key already exists.
         if ("InvalidKeyPair.NotFound" == ex.ErrorCode)
         {
             Console.WriteLine("The key pair \"{0}\" was not found.", keyPair.KeyName);
         }
         else
         {
             // The exception was thrown for another reason, so re-throw the exception.
             throw;
         }
     }
 }