def policy_details(client, module):
 if (module.params.get('max_items') or module.params.get('next_marker')):
  module.fail_json(msg='Cannot specify max_items nor next_marker for query=policy.')
 lambda_facts = dict()
 function_name = module.params.get('function_name')
 if function_name:
  try:
   lambda_facts.update(policy=json.loads(client.get_policy(FunctionName=function_name)['Policy']))
  except ClientError as e:
   if (e.response['Error']['Code'] == 'ResourceNotFoundException'):
    lambda_facts.update(policy={})
   else:
    module.fail_json(msg='Unable to get {0} policy, error: {1}'.format(function_name, e))
 else:
  module.fail_json(msg='Parameter function_name required for query=policy.')
 return {function_name: camel_dict_to_snake_dict(lambda_facts)}

def policy_details ( client , module ) : if ( module . params . get ( 'max_items' ) or module . params . get ( 'next_marker' ) ) : module . fail_json ( msg = 'Cannot specify max_items nor next_marker for query=policy.' ) lambda_facts = dict ( ) function_name = module . params . get ( 'function_name' ) if function_name : try : lambda_facts . update ( policy = json . loads ( client . get_policy ( FunctionName = function_name ) [ 'Policy' ] ) ) except ClientError as e : if ( e . response [ 'Error' ] [ 'Code' ] == 'ResourceNotFoundException' ) : lambda_facts . update ( policy = { } ) else : module . fail_json ( msg = 'Unable to get {0} policy, error: {1}' . format ( function_name , e ) ) else : module . fail_json ( msg = 'Parameter function_name required for query=policy.' ) return { function_name : camel_dict_to_snake_dict ( lambda_facts ) }
returns policy attached to a lambda function .