Viewing: boto_lambda.cpython-36.pyc
3 �N�b5� � @ s� d Z ddlZddlZddlZddlZddlZddlZddlZddl m Z eje�Z yTddlZddlZddlmZ ddlmZ ejd�jej� ejd�jej� dZW n ek r� d ZY nX d d� Zdd � ZdKdd�ZdLdd�ZdMdd�Zdd� ZdNdd�ZdOdd�Z dPdd�Z!dQd d!�Z"dRd"d#�Z#dSd$d%�Z$dTd&d'�Z%dUd(d)�Z&dVd*d+�Z'dWd,d-�Z(dXd.d/�Z)dYd0d1�Z*dZd2d3�Z+d[d4d5�Z,d\d6d7�Z-d]d8d9�Z.d^d:d;�Z/d_d=d>�Z0d`d?d@�Z1dadAdB�Z2dbdCdD�Z3dcdEdF�Z4dddGdH�Z5dedIdJ�Z6dS )fa� Connection module for Amazon Lambda .. versionadded:: 2016.3.0 :depends: - boto - boto3 The dependencies listed above can be installed via package or pip. :configuration: This module accepts explicit Lambda credentials but can also utilize IAM roles assigned to the instance through Instance Profiles. Dynamic credentials are then automatically obtained from AWS API and no further configuration is necessary. More Information available here__. .. __: http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/iam-roles-for-amazon-ec2.html If IAM roles are not used you need to specify them either in a pillar or in the minion's config file: .. code-block:: yaml lambda.keyid: GKTADJGHEIQSXMKKRBJ08H lambda.key: askdjghsdfjkghWupUjasdflkdfklgjsdfjajkghs A region may also be specified in the configuration: .. code-block:: yaml lambda.region: us-east-1 If a region is not specified, the default is us-east-1. It's also possible to specify key, keyid and region via a profile, either as a passed in dict, or as a string to pull from pillars or minion config: .. code-block:: yaml myprofile: keyid: GKTADJGHEIQSXMKKRBJ08H key: askdjghsdfjkghWupUjasdflkdfklgjsdfjajkghs region: us-east-1 .. versionchanged:: 2015.8.0 All methods now return a dictionary. Create and delete methods return: .. code-block:: yaml created: true or .. code-block:: yaml created: false error: message: error message Request methods (e.g., `describe_function`) return: .. code-block:: yaml function: - {...} - {...} or .. code-block:: yaml error: message: error message � N)�SaltInvocationError)�ClientError)�__version__�boto�boto3TFc C s t jjjdddd�S )zg Only load if boto libraries exist and if boto libraries are greater than a given version. z2.8.0z1.2.5z1.5.2)Zboto_verZ boto3_verZbotocore_ver)�salt�utilsZversionsZcheck_boto_reqs� r r �!/usr/lib/python3.6/boto_lambda.py�__virtual__p s r c C s t rtd td� d S )Nzboto3.assign_funcs�lambda)�HAS_BOTO� __utils__�__name__)Zoptsr r r �__init__~ s r c C sN t ||||d�}x8td |j�D ]&}x |d D ]}|d | kr.|S q.W q W dS )zK Given function name, find and return matching Lambda information. )�region�key�keyid�profilezboto3.paged_call� Functions�FunctionNameN)� _get_connr �list_functions)�namer r r r �conn�funcs�funcr r r �_find_function� s r c C sP yt | ||||d�}dt|�iS tk rJ } zdtd |�iS d}~X nX dS )a& Given a function name, check to see if the given function name exists. Returns True if the given function exists and returns False if the given function does not exist. CLI Example: .. code-block:: bash salt myminion boto_lambda.function_exists myfunction )r r r r �exists�errorzboto3.get_errorN)r �boolr r )r r r r r r �er r r �function_exists� s r"