我需要使用java获得注册到特定autoscalinggroup的所有ec2示例的私有ip地址。下面的代码连接到“自动缩放”组,并为我提供所有已注册示例的示例ID。如何从找到的示例ID中获取示例的私有ip地址。
AmazonAutoScaling amazonAutoScaling = AmazonAutoScalingClientBuilder.standard()
.withCredentials(new AWSStaticCredentialsProvider(new BasicAWSCredentials("***", "***")))
.withRegion("us-east-2").build();
DescribeAutoScalingGroupsResult describeAutoScalingGroupsResult =
amazonAutoScaling.describeAutoScalingGroups();
List<AutoScalingGroup> autoScalingGroupList = describeAutoScalingGroupsResult.getAutoScalingGroups();
for(AutoScalingGroup autoScalingGroup: autoScalingGroupList) {
if(autoScalingGroup.getAutoScalingGroupName().equals("trendServerAutoScalingGroup")) {
List<Instance> instances = autoScalingGroup.getInstances();
System.out.println(instances.toString());
for(Instance instance : instances) {
System.out.println(instance.getInstanceId().toString());
//GET IP ADDRESS of the instance ??
}
}
}
暂无答案!
目前还没有任何答案,快来回答吧!