How to get the availability zone details for a running instance

amazon-ec2, java

Solution

The availability zone can be accessed with:

instance.getPlacement().getAvailabilityZone();

Problem

I am iterating through the running instance list returned by DescribeInstances API. I would like to know how can I retrieve the availability zone for each of these instances.

Original source