How to get availability zone information for a running instance

I repeat the list of running instances returned by the DescribeInstances API. I would like to know how I can get the availability zone for each of these instances.

+3
source share
4 answers

Access to the access zone can be obtained using:

instance.getPlacement().getAvailabilityZone();
+11
source

Surprised no one has posted this yet, this is the best, fastest and easiest way to do this AFAIK.

curl -s http://169.254.169.254/latest/meta-data/placement/availability-zone
+11
source

, API, - IP . IP ( AWS ).

0

API:

I did this as follows: 1. Use the API to get the currently available zones. 2. Scroll through the returned zones, set the filter on the DescribeInstances foreach of them and get information about the instance.

-2
source

Source: https://habr.com/ru/post/1779341/


All Articles