3

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");
Kiril Kirilov
  • 11,167
  • 5
  • 49
  • 74

1 Answers1

5

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();
Peter
  • 965
  • 7
  • 13