使用此代码段,我可以在我的 AWS 账户中获取区域列表,但为什么我必须输入区域名称才能获取区域列表(在本例中为“us-east-1”)。
AWSCredentials credentials = new BasicAWSCredentials("accessKey", "secretKey");
AWSCredentialsProvider credentialsProvider=new AWSStaticCredentialsProvider(credentials);
AmazonEC2 ec2 = AmazonEC2ClientBuilder.standard()
.withCredentials(credentialsProvider)
.withRegion("us-east-1")
.build();
DescribeRegionsResult regions_response = ec2.describeRegions();
for(Region region : regions_response.getRegions()) {
System.out.println(region.getRegionName());
}
}