本文介绍了亚马逊AWS的Java API。我看不到我的AMI的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是亚马逊AWS的Java API。我成功进行身份验证,然后得到的所有图像和我的图片不在其中(我的AMI是私有的,但我想我还是会看到他们,因为我已经通过验证)。下面是我的源...

 最后AmazonEC2客户端=新AmazonEC2Client(credentails);

对于(形象画像:client.describeImages()getImages()){
    如果(image.getOwnerId()。等于(1234567890)){
    // ...做一些有用的AMI
    }
}
 

和我的OWNERID是不是中接收到的。这是什么问题,我不会让我的AMI公开,我怎么能得到我的AMI?

答:我是在一个错误的地区,我是从该地区获得唯一的AMI,不是我的。改变区域的方法是:

  client.setEndpoint(ec2.us-west-1.amazonaws.com);
 

解决方案

仅供参考,如果你只关心你自己的情况下,可以大大呼叫使用减少了DescribeInstances使用的带宽量:

  DescribeImagesRequest请求=新DescribeImagesRequest();
request.withOwners(自我);

收藏<图像>照片= client.describeImages(要求).getImages();
 

I'm using the Java API for Amazon AWS. I successfully authenticate, then get all images and my images are not among them (my AMIs are private, but I suppose that I will still see them since I have been authenticated). Here is my source...

final AmazonEC2 client = new AmazonEC2Client(credentails);

for(Image image: client.describeImages().getImages()){
    if(image.getOwnerId().equals("1234567890")){
    //... do something usefull with the AMI
    }
}

And my "OwnerId" is not among the received ones. What is the problem, I won't make my AMIs public, how can I get my AMIs?

ANSWER: I was in a wrong region, and I was getting only AMIs from that region, not mine.The way to change region is:

client.setEndpoint("ec2.us-west-1.amazonaws.com");
解决方案

FYI, if you're only interested in your own instances you can dramatically reduce the amount of bandwidth used in a DescribeInstances call using:

DescribeImagesRequest request = new DescribeImagesRequest();
request.withOwners("self");

Collection<Image> images = client.describeImages(request).getImages();

这篇关于亚马逊AWS的Java API。我看不到我的AMI的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-21 14:06