Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in AWS by (19.1k points)

The IAM user can be referred to in policy documents by ${aws:username}.

If I call describeSnapshots() of AmazonEC2 Java interface I get a big number of snapshots as described in the documentation because it includes all visible snapshots.

However to get the list of my snapshots, should be easy with the API, but it isn't obvious to me. I tried to pass a DescribeSnapshotsRequests object to describeSnapshots()

DescribeSnapshotsRequest req = new DescribeSnapShotRequests();

List<String> ownerId = new ArrayList<String>();

ownerId.add("....");

req.setOwnerIds(ownerId);

DescribeSnapshotsResult res = ec2.describeSnapshots(req);

However, to get my user id, I printed the user id of all snapshots and manually identified mine, copied that user id, and used in the source code.

I hope there is a better way to list my snapshots, anyone knows?

1 Answer

0 votes
by (44.4k points)

Try this

 req.setOwnerIds(Arrays.<String>asList("self"));

This works for me to describe images.

Related questions

0 votes
1 answer

Want to get 50% Hike on your Salary?

Learn how we helped 50,000+ professionals like you !

Browse Categories

...