def create_role_policy(role_name, policy_name, policy, region=None, key=None, keyid=None, profile=None):
 conn = _get_conn(region=region, key=key, keyid=keyid, profile=profile)
 _policy = get_role_policy(role_name, policy_name, region, key, keyid, profile)
 mode = 'create'
 if _policy:
  if (_policy == policy):
   return True
  mode = 'modify'
 if isinstance(policy, six.string_types):
  policy = json.loads(policy, object_pairs_hook=odict.OrderedDict)
 try:
  _policy = json.dumps(policy)
  conn.put_role_policy(role_name, policy_name, _policy)
  if (mode == 'create'):
   msg = 'Successfully added {0} policy to {1} role.'
  else:
   msg = 'Successfully modified {0} policy for role {1}.'
  log.info(msg.format(policy_name, role_name))
  return True
 except boto.exception.BotoServerError as e:
  log.error(e)
  msg = 'Failed to {0} {1} policy for role {2}.'
  log.error(msg.format(mode, policy_name, role_name))
  return False

def create_role_policy ( role_name , policy_name , policy , region = None , key = None , keyid = None , profile = None ) : conn = _get_conn ( region = region , key = key , keyid = keyid , profile = profile ) _policy = get_role_policy ( role_name , policy_name , region , key , keyid , profile ) mode = 'create' if _policy : if ( _policy == policy ) : return True mode = 'modify' if isinstance ( policy , six . string_types ) : policy = json . loads ( policy , object_pairs_hook = odict . OrderedDict ) try : _policy = json . dumps ( policy ) conn . put_role_policy ( role_name , policy_name , _policy ) if ( mode == 'create' ) : msg = 'Successfully added {0} policy to {1} role.' else : msg = 'Successfully modified {0} policy for role {1}.' log . info ( msg . format ( policy_name , role_name ) ) return True except boto . exception . BotoServerError as e : log . error ( e ) msg = 'Failed to {0} {1} policy for role {2}.' log . error ( msg . format ( mode , policy_name , role_name ) ) return False
create or modify a role policy .