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(); }
public void ElasticLoadBalancingDescribeLoadBalancers() { #region elb-describe-load-balancers-1 var response = client.DescribeLoadBalancers(new DescribeLoadBalancersRequest { LoadBalancerNames = new List <string> { "my-load-balancer" } }); List <LoadBalancerDescription> loadBalancerDescriptions = response.LoadBalancerDescriptions; #endregion }
IEnumerable <DescribeLoadBalancersResponse> IPaginator <DescribeLoadBalancersResponse> .Paginate() { if (Interlocked.Exchange(ref _isPaginatorInUse, 1) != 0) { throw new System.InvalidOperationException("Paginator has already been consumed and cannot be reused. Please create a new instance."); } var marker = _request.Marker; DescribeLoadBalancersResponse response; do { _request.Marker = marker; response = _client.DescribeLoadBalancers(_request); marker = response.NextMarker; yield return(response); }while (marker != null); }
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.DescribeLoadBalancersResponse CallAWSServiceOperation(IAmazonElasticLoadBalancing client, Amazon.ElasticLoadBalancing.Model.DescribeLoadBalancersRequest request) { Utils.Common.WriteVerboseEndpointMessage(this, client.Config, "Elastic Load Balancing", "DescribeLoadBalancers"); try { #if DESKTOP return(client.DescribeLoadBalancers(request)); #elif CORECLR return(client.DescribeLoadBalancersAsync(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; } }
public DescribeLoadBalancersResponse GetAllLBs() { _statusProvider.UpdateStatus("BUSY: Getting Loadbalancer details..."); // var x = _LBservice.DescribeLoadBalancers(); return(_LBservice.DescribeLoadBalancers()); }