AWS Java SDK DescribeLoadBalancersResult возвращает пустой ответ

#java #amazon-web-services #aws-sdk

#java #amazon-web-services #aws-sdk

Вопрос:

AWS Java API [DescribeLoadBalancersResult][1] возвращает пустые описания балансировщиков нагрузки после предоставления правильных кодов регионов и учетных данных aws. В AWS есть балансировщики нагрузки, и они возвращаются через CLI

 public void getELB(String accessKey, String secretKey, String region, String... elbids) throws Exception {
        AmazonElasticLoadBalancingClient amazonElasticLoadBalancingClient = new EC2Client().getELBClient(accessKey,
                secretKey, region);
        DescribeLoadBalancersResult describeLoadBalancersResult = amazonElasticLoadBalancingClient.describeLoadBalancers();
        System.out.println(describeLoadBalancersResult);
        List<LoadBalancerDescription> balancerDescriptions = describeLoadBalancersResult.getLoadBalancerDescriptions();
        for (Iterator iterator = balancerDescriptions.iterator(); iterator.hasNext();) {
            LoadBalancerDescription loadBalancerDescription = (LoadBalancerDescription) iterator.next();
            System.out.println(loadBalancerDescription);
            
        }
    }
 

Вывод ИТ

 {LoadBalancerDescriptions: [],}
 

Вот метод создания AmazonElasticLoadBalancingClient

 public AmazonElasticLoadBalancingClient  getELBClient(String accessKey, String secretKey, String region) throws Exception {
        AWSCredentialsProvider provider;
        if (accessKey != null amp;amp; secretKey != null) {
            AWSCredentials credentials = new BasicAWSCredentials(accessKey, secretKey);
            provider = new StaticCredentialsProvider(credentials);
        } else {
            provider = new DefaultAWSCredentialsProviderChain();
        }
        AmazonElasticLoadBalancingClient client = new AmazonElasticLoadBalancingClient(provider).withRegion(Regions.fromName(region));
        ClientConfiguration configuration = new ClientConfiguration();
        configuration.setProtocol(Protocol.HTTPS);
        return client;
    }


  [1]: https://docs.aws.amazon.com/AWSJavaSDK/latest/javadoc/com/amazonaws/services/elasticloadbalancing/model/DescribeLoadBalancersResult.html