title: Python boto3 (AWS EC2) list Nested JSON Data
body: <p>I use <a href="https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/ec2.html" rel="nofollow noreferrer">boto3</a> to get a list of all instances like this.</p>
  <pre><code>id: i-fa512784, zone: us-east-1, state: running, name: redis, env: staging-db, app: php
  id: i-fa112784, zone: us-east-1, state: running, name: redis, env: production, app: php
  </code></pre>
  <p>I would like to create a single string for all values per instance. I.e. each of instances should have own string with own keys. My goal is to put this data into Prometheus.</p>
  <p>I have got stuck on parsing nested <code>&quot;Tags&quot;: [</code> to get all values and output all of them into one string</p>
  <p>My code</p>
  <pre><code>#!/usr/bin/python3
  
  import boto3.utils
  boto3.setup_default_session(profile_name='profile')
  client = boto3.client('ec2')
  
  response = client.describe_instances(
     MaxResults=10,
  )
  
  for r in response['Reservations']:
      for i in r['Instances']:
          for tags in i['Tags']:
          print ('id:',i['InstanceId'], 'zone:',i['Placement']['AvailabilityZone'], 'state:',i['State']['Name'])
  </code></pre>
  <p>Thank you in advance</p>