Why do I get this whenever I am trying to get the network interfaces?
com.amazonaws.services.ec2.model.AmazonEC2Exception: null (Service: AmazonEC2; Status Code: 400; Error Code: 400 Bad Request; Request ID: null)
at com.amazonaws.http.AmazonHttpClient$RequestExecutor.handleErrorResponse(AmazonHttpClient.java:1639)
at com.amazonaws.http.AmazonHttpClient$RequestExecutor.executeOneRequest(AmazonHttpClient.java:1304)
at com.amazonaws.http.AmazonHttpClient$RequestExecutor.executeHelper(AmazonHttpClient.java:1056)
at com.amazonaws.http.AmazonHttpClient$RequestExecutor.doExecute(AmazonHttpClient.java:743)
at com.amazonaws.http.AmazonHttpClient$RequestExecutor.executeWithTimer(AmazonHttpClient.java:717)
at com.amazonaws.http.AmazonHttpClient$RequestExecutor.execute(AmazonHttpClient.java:699)
at com.amazonaws.http.AmazonHttpClient$RequestExecutor.access$500(AmazonHttpClient.java:667)
at com.amazonaws.http.AmazonHttpClient$RequestExecutionBuilderImpl.execute(AmazonHttpClient.java:649)
at com.amazonaws.http.AmazonHttpClient.execute(AmazonHttpClient.java:513)
at com.amazonaws.services.ec2.AmazonEC2Client.doInvoke(AmazonEC2Client.java:15651)
at com.amazonaws.services.ec2.AmazonEC2Client.invoke(AmazonEC2Client.java:15627)
at com.amazonaws.services.ec2.AmazonEC2Client.executeDescribeInstances(AmazonEC2Client.java:7621)
at com.amazonaws.services.ec2.AmazonEC2Client.describeInstances(AmazonEC2Client.java:7597)
at com.amazonaws.services.ec2.AmazonEC2Client.describeInstances(AmazonEC2Client.java:7633)
I am using below code for example. This is the only code for testing.
AmazonEC2 amazonEC2 = getEC2Client(); try { DescribeInstancesResult result = amazonEC2.describeInstances(); for(Reservation reservation : result.getReservations()){ System.out.println(reservation.getInstances()); } }catch (AmazonEC2Exception e){ e.printStackTrace(); } protected static AmazonEC2 getEC2Client() { conf = new ClientConfiguration(); conf.setConnectionTimeout(5000); conf.setSocketTimeout(20000); conf.setMaxErrorRetry(2); AmazonEC2 client; if (access_id == null && access_key == null) { client = AmazonEC2ClientBuilder.standard().withClientConfiguration(conf).withEndpointConfiguration(new AwsClientBuilder.EndpointConfiguration("https://iam.amazonaws.com", "us-east-1")) .withCredentials(new InstanceProfileCredentialsProvider(false)) .build(); } else { client = AmazonEC2ClientBuilder.standard().withClientConfiguration(conf).withEndpointConfiguration(new AwsClientBuilder.EndpointConfiguration("https://iam.amazonaws.com","us-east-1")) .withCredentials(new AWSStaticCredentialsProvider(new BasicAWSCredentials(access_id, access_key))) .build(); } return client; }
I can access the list of Users in the same class but not the stuff related to Describe*
can anyone please help me in this case ?