#!python
# -*- coding: utf-8 -*-

# This program is free software. It comes without any warranty, to
# the extent permitted by applicable law. You can redistribute it
# and/or modify it under the terms of the Do What The Fuck You Want
# To Public License, Version 2, as published by Sam Hocevar. See
# http://www.wtfpl.net/ for more details.

import boto3

client = boto3.client('ec2')
instances = client.describe_instances(
    Filters=[
        {
            'Name': 'tag:Name',
            'Values': [
                '*'
            ]
        },
        {
            'Name': 'instance-state-name',
            'Values': ['running']
        }
    ],
    MaxResults=100,
)
del client
for host in instances['Reservations']:
    for tag in host['Instances'][0]['Tags']:
        if tag['Key'] == 'Name':
            print('Host ' + tag['Value'])
    print('    HostName ' + host['Instances'][0]['PublicIpAddress'])
    print('    User ubuntu')
    print('')
