%PDF- %PDF-
Direktori : /usr/lib/python2.7/site-packages/salt/states/ |
Current File : //usr/lib/python2.7/site-packages/salt/states/boto_iam_role.pyc |
� ���^c @@ s� d Z d d l m Z m Z m Z d d l Z d d l j j Z d d l m Z d d l Z d d l m Z e j e � Z d � Z d d d d d d e d d d d e d � Z d d d d d d d � Z d d d d d � Z d d d d d � Z d � Z d d d d d e d � Z d d d d d d � Z d d d d d � Z d d d d d � Z d d d d d � Z d d d d d � Z d d d d d � Z d d d d d � Z! d S( uq Manage IAM roles ================ .. versionadded:: 2014.7.0 This module uses ``boto``, which can be installed via package, or pip. This module accepts explicit IAM 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 file or in the minion's config file: .. code-block:: yaml iam.keyid: GKTADJGHEIQSXMKKRBJ08H iam.key: askdjghsdfjkghWupUjasdflkdfklgjsdfjajkghs It's also possible to specify ``key``, ``keyid`` and ``region`` via a profile, either passed in as a dict, or as a string to pull from pillars or minion config: .. code-block:: yaml myprofile: keyid: GKTADJGHEIQSXMKKRBJ08H key: askjghsdfjkghWupUjasdflkdfklgjsdfjajkghs region: us-east-1 Creating a role will automatically create an instance profile and associate it with the role. This is the default behavior of the AWS console. .. code-block:: yaml myrole: boto_iam_role.present: - region: us-east-1 - key: GKTADJGHEIQSXMKKRBJ08H - keyid: askdjghsdfjkghWupUjasdflkdfklgjsdfjajkghs - policies_from_pillars: - shared_iam_bootstrap_policy - policies: MySQSPolicy: Statement: - Action: - sqs:* Effect: Allow Resource: - arn:aws:sqs:*:*:* Sid: MyPolicySQS1 MyS3Policy: Statement: - Action: - s3:GetObject Effect: Allow Resource: - arn:aws:s3:*:*:mybucket/* # Using a credentials profile from pillars myrole: boto_iam_role.present: - profile: myiamprofile # Passing in a credentials profile myrole: boto_iam_role.present: - profile: key: GKTADJGHEIQSXMKKRBJ08H keyid: askdjghsdfjkghWupUjasdflkdfklgjsdfjajkghs region: us-east-1 If ``delete_policies: False`` is specified, existing policies that are not in the given list of policies will not be deleted. This allows manual modifications on the IAM role to be persistent. This functionality was added in 2015.8.0. .. note:: When using the ``profile`` parameter and ``region`` is set outside of the profile group, region is ignored and a default region will be used. If ``region`` is missing from the ``profile`` data set, ``us-east-1`` will be used as the default region. i ( t absolute_importt print_functiont unicode_literalsN( t OrderedDict( t sixc C@ s d t k r d St S( u) Only load if boto is available. u boto_iam.role_existsu boto_iam_role( t __salt__t False( ( ( s= /usr/lib/python2.7/site-packages/salt/states/boto_iam_role.pyt __virtual__c s c C@ s� i | d 6t d 6d d 6i d 6} i } | r} t d | � } | r} | d | d <| j d g � | d j | d � q} n | r� | d | d <| j d g � | d j | d � n t | | | | | | | � } | s� i } n | s� g } n | sg } n i } x+ | D]# } t d | � } | j | � qW| j | � | d | d <d j | d | d g � | d <| d s�| d | d <| d t k r�| Sn | r�t | | | | | � } t j | d | d � | d <d j | d | d g � | d <| d s/| d | d <| d t k r/| Sn t | | | | | � } t j | d | d � | d <d j | d | d g � | d <| d s�| d | d <| d t k r�| Sq�n t | | | | | | | � } t j | d | d � | d <d j | d | d g � | d <| d s0| d | d <n t | | | | | | � } t j | d | d � | d <d j | d | d g � | d <| d s�| d | d <n | S( u Ensure the IAM role exists. name Name of the IAM role. policy_document The policy that grants an entity permission to assume the role. (See https://boto.readthedocs.io/en/latest/ref/iam.html#boto.iam.connection.IAMConnection.create_role) policy_document_from_pillars A pillar key that contains a role policy document. The statements defined here will be appended with the policy document statements defined in the policy_document argument. .. versionadded:: 2017.7.0 path The path to the role/instance profile. (See https://boto.readthedocs.io/en/latest/ref/iam.html#boto.iam.connection.IAMConnection.create_role) policies A dict of IAM role policies. policies_from_pillars A list of pillars that contain role policy dicts. Policies in the pillars will be merged in the order defined in the list and key conflicts will be handled by later defined keys overriding earlier defined keys. The policies defined here will be merged with the policies defined in the policies argument. If keys conflict, the keys in the policies argument will override the keys defined in policies_from_pillars. managed_policies A list of (AWS or Customer) managed policies to be attached to the role. create_instance_profile A boolean of whether or not to create an instance profile and associate it with this role. region Region to connect to. key Secret key to be used. keyid Access key to be used. profile A dict with region, key and keyid, or a pillar key (string) that contains a dict with region, key and keyid. delete_policies Deletes existing policies that are not in the given list of policies. Default value is ``True``. If ``False`` is specified, existing policies will not be deleted allowing manual modifications on the IAM role to be persistent. .. versionadded:: 2015.8.0 u nameu resultu u commentu changesu pillar.getu Versionu Statementu ( t TrueR t setdefaultt extendt _role_presentt updatet joinR t _instance_profile_presentt dictupdatet _instance_profile_associatedt _policies_presentt _policies_attached( t namet policy_documentt policy_document_from_pillarst patht policiest policies_from_pillarst managed_policiest create_instance_profilet regiont keyt keyidt profilet delete_policiest rett _policy_documentt from_pillarst _rett _policiest policyt _policy( ( s= /usr/lib/python2.7/site-packages/salt/states/boto_iam_role.pyt presentj st J" ! ! ! ! ! c C@ s2 i t d 6d d 6i d 6} t d | | | | | � } | s� t d rh d j | � | d <d | d <| St d | | | | | | | � } | r� i d d 6| d d <i | d 6| d d <d j | � | d <q.t | d <d j | � | d <n>d j | � | d <| s%t d | | | | � } n | } t j j j t | d � t | � � r.t d r�d } d j | d | � | d <d | d <| St d | | | | | | � } | rd } d j | d | � | d <i | d d 6| d d <i | d 6| d d <q.t | d <d } d j | d | � | d <n | S( Nu resultu u commentu changesu boto_iam.describe_roleu testu"