Beispiel #1
0
        public void updateInstanceIdFromName()
        {
            List <InstanceRequest> InstanceRequestList = validEC2Instances();
            InstanceRequest        filteredObj         = InstanceRequestList.Find(x => x.InstanceName.ToLower() == InstanceRequestObj.InstanceName.ToLower());

            InstanceRequestObj.InstanceID    = filteredObj.InstanceID;
            InstanceRequestObj.InstanceState = filteredObj.InstanceState;
        }
Beispiel #2
0
        private void DescribeInstance(ref bool actionSucceeded, ref string actionMessage)
        {
            try
            {
                List <InstanceRequest> InstanceRequestList = validEC2Instances();
                InstanceRequest        filteredInstance    = InstanceRequestList.Find(x => x.InstanceID == InstanceRequestObj.InstanceID);
                InstanceRequestObj.InstanceState = filteredInstance.InstanceState;

                actionSucceeded = true;
                actionMessage   = $"Your instance {InstanceRequestObj.InstanceName} is currently in {InstanceRequestObj.InstanceState} state.";
            }
            catch (Exception ex)
            {
                context.Logger.LogLine($"ServerOperationsHelper::DescribeInstance {ex.Message}");
                context.Logger.LogLine($"ServerOperationsHelper::DescribeInstance {ex.StackTrace}");
                actionSucceeded = false;
                actionMessage   = $"Could not start {InstanceRequestObj.InstanceName} . Please contact your administrator.";
            }
        }
Beispiel #3
0
 public ServerOperationsHelper(bool isLocalDebug, InstanceRequest instanceRequest, ILambdaContext context)
 {
     this.IsLocalDebug       = isLocalDebug;
     this.InstanceRequestObj = instanceRequest;
     this.context            = context;
     if (isLocalDebug)
     {
         var            chain = new CredentialProfileStoreChain();
         AWSCredentials awsCredentials;
         if (chain.TryGetAWSCredentials(Constants.AWSProfileName, out awsCredentials))
         {
             // use awsCredentials
             Ec2Client = new AmazonEC2Client(awsCredentials, Amazon.RegionEndpoint.USEast1);
         }
     }
     else
     {
         Ec2Client = new AmazonEC2Client();
     }
     updateInstanceIdFromName();
 }