title: Returning AWS EC2 availability_zone attribute using boto3 Python SDK
body: <p>I am trying to return information about all of the <code>EC2</code> instances in an <code>AWS</code> account using <code>boto3</code> <code>API</code> calls in <code>Python</code>, but I cannot get the <code>availability_zone</code> resource to display.</p>
  
  <p>For instance, when I can iterate over all of my <code>EC2</code> instances successfully using this code:</p>
  
  <pre><code>ec2 = boto3.resource('ec2')
  
  output = defaultdict()
  
  for instance in ec2.instances.all()
      for iface in instance.network_interfaces:
          output[instance.id] = {
              'Instance ID': instance.id,
              'Subnet ID': iface.subnet_id
          }
  </code></pre>
  
  <p>I am leaving out the rest of the code, but the above works and outputs the values of those resources which I then put into a <code>csv</code> file using <code>Pandas</code> <code>.to_csv</code>.</p>
  
  <p>When I try to add the following as a value in the <code>Python</code> <code>dictionary</code>:</p>
  
  <pre><code>'Availability Zone': instance.availability_zone
  </code></pre>
  
  <p>I get the following error:</p>
  
  <pre><code>AttributeError: 'ec2.Instance' object has no attribute 'availability_zone'
  </code></pre>
  
  <p>That's the expected behavior. I then try the following instead:</p>
  
  <pre><code>'Availability Zone': iface.availability_zone
  </code></pre>
  
  <p>This runs with error, but the output is null. There simple isn't anything in the <code>csv</code> file.</p>
  
  <p>I looked at the <code>boto3</code> <a href="https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/ec2.html?highlight=availability%20zone#networkinterface" rel="nofollow noreferrer">documentation</a>, and <code>availability_zone</code> is an available resource attribute under the <code>NetworkInterface</code> resource, just like <code>subnet_id</code>, which I am using and is working.</p>
  
  <p>What am I missing here? Can anyone point me in the right direction or let me know what I am doing wrong?</p>