private static void StopInstance() { try { AmazonEC2 ec2 = AWSClientFactory.CreateAmazonEC2Client(_awsKey, _awsSecretKey); StopInstancesRequest request = new StopInstancesRequest(); request.WithInstanceId(new string[] { _instanceId }); ec2.StopInstances(request); Mail(string.Format("Successfully stopped EC2 instance {0}", _instanceId)); } catch (Exception e) { MailError("Error stopping instance", e); } }