I am developing an application in Java and I am able to list the instances:
for (Reservation reservation : result.getReservations()) {
for (Instance instance : reservation.getInstances()) {
System.out.println("Instance id:"
+ instance.getInstanceId());
}
}
How do I get the instance name?
You can access tags associated with the instance:
for (Reservation reservation : result.getReservations()) {
for (Instance instance : reservation.getInstances()) {
System.out.println("Instance id:" + instance.getInstanceId());
if (instance.getTags() != null) {
for (Tag tag : instance.getTags()) {
System.out.println(String.format(
"%s: %s",
tag.getKey(),
tag.getValue()
));
}
}
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With