def ec2_info(aws_config=None, instance_id=None): """ @type aws_config: Config @type instance_id: unicode """ ec2_client = get_client(client_type='ec2', config=aws_config) ec2_query = ec2_client.describe_instances(Filters=[{'Name': 'instance-id', 'Values': [instance_id]}]) reservations = ec2_query.get('Reservations') try: instance = reservations[0].get('Instances')[0] if instance.get('InstanceId'): output_ec2_info(instance=instance) except IndexError: raise SystemExit("Cannot find instance: {0}".format(instance_id))
def ec2_info(aws_config=None, instance_id=None): """ @type aws_config: Config @type instance_id: unicode """ ec2_client = get_client(client_type='ec2', config=aws_config) ec2_query = ec2_client.describe_instances(Filters=[{ 'Name': 'instance-id', 'Values': [instance_id] }]) reservations = ec2_query.get('Reservations') try: instance = reservations[0].get('Instances')[0] if instance.get('InstanceId'): output_ec2_info(instance=instance) except IndexError: raise SystemExit("Cannot find instance: {0}".format(instance_id))
def test_ec2_output(ec2_instances): with pytest.raises(SystemExit): instance = list(ec2_instances)[0] assert output_ec2_info(instance=instance)