1

I hava AmazonEC2Client connected to my account. I can ask AWS my Reservations and Instances by

DescribeInstancesResult describeInstancesRequest = amazonEC2Client.describeInstances();
List<Reservation> reservations = describeInstancesRequest.getReservations();
Set<Instance> instances = new HashSet<Instance>();

for (Reservation reservation : reservations) {
   instances.addAll(reservation.getInstances());
}

But if I already know the Id of instance, can I somehow get Instance object for it without requesting reservations and all instances?

1 Answer 1

1

You need to use :
describeInstances (DescribeInstancesRequest describeInstancesRequest)
instead of
describeInstances().

You can set the instanceId in the DescribeInstancesRequest.
You need to use the setInstanceIds(Collection<String> instanceIds) method of DescribeInstancesRequest to set the instanceId(s) you are searching for.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.