def get_or_create_mrjob_instance_profile(conn):
 for (profile_name, role_name, role_document) in _yield_instance_profiles(conn):
  if (role_document != _MRJOB_INSTANCE_PROFILE_ROLE):
   continue
  policy_arns = list(_yield_attached_role_policies(conn, role_name))
  if (policy_arns == [_EMR_INSTANCE_PROFILE_POLICY_ARN]):
   return role_name
 name = _create_mrjob_role_with_attached_policy(conn, _MRJOB_INSTANCE_PROFILE_ROLE, _EMR_INSTANCE_PROFILE_POLICY_ARN)
 conn.create_instance_profile(name)
 conn.add_role_to_instance_profile(name, name)
 log.info(('Auto-created instance profile %s' % name))
 return name

def get_or_create_mrjob_instance_profile ( conn ) : for ( profile_name , role_name , role_document ) in _yield_instance_profiles ( conn ) : if ( role_document != _MRJOB_INSTANCE_PROFILE_ROLE ) : continue policy_arns = list ( _yield_attached_role_policies ( conn , role_name ) ) if ( policy_arns == [ _EMR_INSTANCE_PROFILE_POLICY_ARN ] ) : return role_name name = _create_mrjob_role_with_attached_policy ( conn , _MRJOB_INSTANCE_PROFILE_ROLE , _EMR_INSTANCE_PROFILE_POLICY_ARN ) conn . create_instance_profile ( name ) conn . add_role_to_instance_profile ( name , name ) log . info ( ( 'Auto-created instance profile %s' % name ) ) return name
look for a usable instance profile for emr .