我正在用Java开发一个应用程序,我能够列出实例:
for (Reservation reservation : result.getReservations()) { for (Instance instance : reservation.getInstances()) { System.out.println("Instance id:" + instance.getInstanceId()); } }
如何获取实例名称?
您可以访问与实例关联的标记:
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() )); } } } }