def ec2_fab(service, args):
instance_ids = args.instances<EOL>instances = service.list(elb=args.elb, instance_ids=instance_ids)<EOL>hosts = service.resolve_hosts(instances)<EOL>fab.env.hosts = hosts<EOL>fab.env.key_filename = settings.get('<STR_LIT>', '<STR_LIT>')<EOL>fab.env.user = settings.get('<STR_LIT>', '<STR_LIT>', getpass.getuser())<EOL>fab.env.parallel = True<EOL>fabfile = find_fabfile(args.file)<EOL>if not fabfile:<EOL><INDENT>print('<STR_LIT>')<EOL>return<EOL><DEDENT>fab.env.real_fabile = fabfile<EOL>docstring, callables, default = load_fabfile(fabfile)<EOL>fab_state.commands.update(callables)<EOL>commands_to_run = parse_arguments(args.methods)<EOL>for name, args, kwargs, arg_hosts, arg_roles, arg_exclude_hosts in commands_to_run:<EOL><INDENT>fab.execute(name,<EOL>hosts=arg_hosts,<EOL>roles=arg_roles,<EOL>exclude_hosts=arg_exclude_hosts,<EOL>*args, **kwargs)<EOL><DEDENT>
Run Fabric commands against EC2 instances