Let's say you want to query some information for one of your instances, like the volumes associated with it:
Using the AWS CLI, you might do something like this to traverse the lists within lists:
aws ec2 describe-instances --instance-ids i-3e9217aa --query Reservations[*].Instances[*].BlockDeviceMappings[*] .Ebs.VolumeId
Assuming your using an Ansible dynamic inventory, you can traverse the sub-lists of your inventory like this:
- debug:
msg: "{{ item.1.volume_id }}"
with_subelements:
- "{{ ec2.instances }}"
- "block_device_mapping"