Пример #1
0
        public async Task <OperationDetails> StopEC2InstancesByInstanceIds(List <string> instanceIds)
        {
            OperationDetails operationDetails = new OperationDetails();

            try
            {
                using (AmazonEC2Client ec2Client = new AmazonEC2Client())
                {
                    StopInstancesRequest stopRequest = new StopInstancesRequest(instanceIds);

                    StopInstancesResponse stopResponse = await ec2Client.StopInstancesAsync(stopRequest);

                    operationDetails.StatusMessage = stopResponse != null?stopResponse.HttpStatusCode.ToString() : "null response";
                }
            }
            catch (Exception ex)
            {
                operationDetails.StatusMessage = ex.Message;
            }

            return(operationDetails);
        }