AmazonEC2 exception case need help

0 votes

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 ?

Apr 17, 2018 in AWS by Cloud gunner
• 4,670 points
1,081 views

1 answer to this question.

0 votes

Try to use .withRegion(..) and do not use .withEndpointConfiguration(...)

Perhaps you use incorrect endpoint definition.

answered Aug 13, 2018 by bug_seeker
• 15,510 points

Related Questions In AWS

0 votes
1 answer
+1 vote
10 answers
+1 vote
1 answer

How to add SSL certificate to AWS EC2 with the help of new AWS Certificate Manager service

refer this link  https://aws.amazon.com/certificate-manager/faqs/ You can't install the certificates ...READ MORE

answered Jul 19, 2018 in AWS by Priyaj
• 58,020 points
1,856 views
0 votes
1 answer

Do i need Amazon Route53 to bind domain to EC2?

You need to assign an Elastic IP ...READ MORE

answered Aug 23, 2018 in AWS by Archana
• 4,170 points
1,453 views
0 votes
1 answer

Task Canceled Exception while invoking AWS Lambda

I'm guessing either the TaskCanceledException instance is ...READ MORE

answered Sep 19, 2018 in AWS by Priyaj
• 58,020 points
2,453 views
+1 vote
1 answer

How to issue a parsing json from case class using jackson?

Do you use jackson-module-scala or any other Scala-aware configuration ...READ MORE

answered Sep 26, 2018 in AWS by Priyaj
• 58,020 points
3,030 views
+2 votes
1 answer

Deploy Docker Containers from Docker Cloud

To solve this problem, I followed advice ...READ MORE

answered Sep 3, 2018 in AWS by Priyaj
• 58,020 points
2,706 views
+15 votes
2 answers

Git management technique when there are multiple customers and need multiple customization?

Consider this - In 'extended' Git-Flow, (Git-Multi-Flow, ...READ MORE

answered Mar 27, 2018 in DevOps & Agile by DragonLord999
• 8,450 points
4,024 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP