public static void InvokeDescribeLoadBalancers()
        {
            NameValueCollection appConfig = ConfigurationManager.AppSettings;

            // Print the number of Elastic Load Balancing domains.
            IAmazonElasticLoadBalancing elb = AWSClientFactory.CreateAmazonElasticLoadBalancingClient(RegionEndpoint.USWest2);

            try
            {
                DescribeLoadBalancersResponse elbResponse = elb.DescribeLoadBalancers(new DescribeLoadBalancersRequest());

                int numLoadBalancers = 0;
                numLoadBalancers = elbResponse.LoadBalancerDescriptions.Count;
                Console.WriteLine("You have " + numLoadBalancers + " Elastic Load Balancing load balancer(s).");
            }
            catch (AmazonElasticLoadBalancingException ex)
            {
                if (ex.ErrorCode.Equals("OptInRequired"))
                {
                    Console.WriteLine("You are not signed for Amazon EC2.");
                    Console.WriteLine("You can sign up at http://aws.amazon.com/ec2.");
                }
                else
                {
                    Console.WriteLine("Caught Exception: " + ex.Message);
                    Console.WriteLine("Response Status Code: " + ex.StatusCode);
                    Console.WriteLine("Error Code: " + ex.ErrorCode);
                    Console.WriteLine("Error Type: " + ex.ErrorType);
                    Console.WriteLine("Request ID: " + ex.RequestId);
                }
            }
            Console.WriteLine();
        }
Ejemplo n.º 2
0
        public ElbSource(IAmazonElasticLoadBalancing client)
        {
            if (client == null)
            {
                throw new ArgumentNullException(nameof(client));
            }

            _client = client;
        }
        public M201602102135_CreateEC2WebLoadBalancer(MigrationContext context)
        {
            if (context == null) throw new ArgumentNullException(nameof(context));

            _context = context;
            _client = CreateClient();
            _ec2client = CreateEc2Client();
            _cluster = _context.Settings.Cluster;
            _task = _cluster.GetTask("web");
        }
        public M201602102135_CreateEC2WebLoadBalancer(MigrationContext context)
        {
            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }

            _context   = context;
            _client    = CreateClient();
            _ec2client = CreateEc2Client();
            _cluster   = _context.Settings.Cluster;
            _task      = _cluster.GetTask("web");
        }
Ejemplo n.º 5
0
 public static IAmazonElasticLoadBalancing createLBClient(string accessKeyID, string secretKeyID, Amazon.RegionEndpoint region)
 {
     try
     {
         _LBservice = new AmazonElasticLoadBalancingClient(accessKeyID, secretKeyID, new AmazonElasticLoadBalancingConfig()
         {
             RegionEndpoint = region
         });
         return(_LBservice);
     }
     catch (AmazonElasticLoadBalancingException ex)
     {
         throw ex;
     }
 }
Ejemplo n.º 6
0
        public static void GetTopology()
        {
            IAmazonEC2                  ec2 = AWSClientFactory.CreateAmazonEC2Client();
            IAmazonAutoScaling          asg = AWSClientFactory.CreateAmazonAutoScalingClient();
            IAmazonElasticLoadBalancing elb = AWSClientFactory.CreateAmazonElasticLoadBalancingClient();

            DescribeVpcsResponse vpcResponse = ec2.DescribeVpcs();

            WriteFile("vpcs.csv", vpcResponse.Vpcs);

            DescribeInstancesResponse instanceResponse = ec2.DescribeInstances();
            var reservationIndex = 0;

            foreach (var reservation in instanceResponse.Reservations)
            {
                if (reservationIndex == 0)
                {
                    WriteFile("instances.csv", reservation.Instances);
                }
                else
                {
                    AppendFile("instances.csv", reservation.Instances);
                }
                reservationIndex++;
            }

            DescribeNetworkAclsResponse naclResponse = ec2.DescribeNetworkAcls();

            WriteFile("nacls.csv", naclResponse.NetworkAcls);

            Amazon.EC2.Model.DescribeTagsResponse tagsResponse = ec2.DescribeTags();
            WriteFile("tags.csv", tagsResponse.Tags);

            DescribeVolumesResponse volumesResponse = ec2.DescribeVolumes();

            WriteFile("volumes.csv", volumesResponse.Volumes);

            DescribeLoadBalancersResponse elbResponse = elb.DescribeLoadBalancers();

            WriteFile("elbs.csv", elbResponse.LoadBalancerDescriptions);

            DescribeInternetGatewaysResponse igResponse = ec2.DescribeInternetGateways();

            WriteFile("igs.csv", igResponse.InternetGateways);
        }
 private Amazon.ElasticLoadBalancing.Model.CreateLoadBalancerListenersResponse CallAWSServiceOperation(IAmazonElasticLoadBalancing client, Amazon.ElasticLoadBalancing.Model.CreateLoadBalancerListenersRequest request)
 {
     Utils.Common.WriteVerboseEndpointMessage(this, client.Config, "Elastic Load Balancing", "CreateLoadBalancerListeners");
     try
     {
         #if DESKTOP
         return(client.CreateLoadBalancerListeners(request));
         #elif CORECLR
         return(client.CreateLoadBalancerListenersAsync(request).GetAwaiter().GetResult());
         #else
                 #error "Unknown build edition"
         #endif
     }
     catch (AmazonServiceException exc)
     {
         var webException = exc.InnerException as System.Net.WebException;
         if (webException != null)
         {
             throw new Exception(Utils.Common.FormatNameResolutionFailureMessage(client.Config, webException.Message), webException);
         }
         throw;
     }
 }
        protected override void ProcessRecord()
        {
            base.ProcessRecord();

            Client = CreateClient(_CurrentCredentials, _RegionEndpoint);
        }
Ejemplo n.º 9
0
 AwsObjectRetriever(IAmazonElasticLoadBalancing client)
 {
     _LBservice = client;
 }
Ejemplo n.º 10
0
 internal ElasticLoadBalancingPaginatorFactory(IAmazonElasticLoadBalancing client)
 {
     this.client = client;
 }
Ejemplo n.º 11
0
 public static DescribeTags DescribeTags(this IAmazonElasticLoadBalancing alb) => new DescribeTags(alb);
Ejemplo n.º 12
0
 public DescribeTags(IAmazonElasticLoadBalancing alb) : base(alb.DescribeTagsAsync)
 {
 }
Ejemplo n.º 13
0
 internal DescribeLoadBalancersPaginator(IAmazonElasticLoadBalancing client, DescribeLoadBalancersRequest request)
 {
     this._client  = client;
     this._request = request;
 }