File manager - Edit - /opt/saltstack/salt/lib/python3.10/site-packages/salt/modules/__pycache__/boto_iam.cpython-310.pyc
Back
o ;jN. � @ s� d Z ddlZddlZddlZddlmZ ddlZddl Zddl Zz&ddlZddlZddl ZddlZe�d��ej� e�d��ej� dZW n eyQ dZY nw e�e�Zdd � Zd d� Zd�dd �Zd�dd�Zd�dd�Zd�dd�Zd�dd�Zd�dd�Z d�dd�Zd�dd�Z d�dd�Z d�dd�Z!d�d d!�Z" d�d"d#�Z#d�d$d%�Z$d�d&d'�Z% d�d(d)�Z& d�d*d+�Z' d�d,d-�Z( d�d.d/�Z) d�d0d1�Z* d�d2d3�Z+d�d5d6�Z, d�d7d8�Z- d�d9d:�Z.d�d;d<�Z/d�d=d>�Z0 d�d?d@�Z1d�dAdB�Z2d�dCdD�Z3 d�dEdF�Z4d�dGdH�Z5 d�dIdJ�Z6d�dKdL�Z7 d�dMdN�Z8d�dOdP�Z9dQdR� Z: d�dSdT�Z; d�dUdV�Z<d�dWdX�Z= d�dYdZ�Z> d�d[d\�Z? d�d]d^�Z@ d�d_d`�ZAd�dadb�ZBd�dcdd�ZCd�dedf�ZDd�dgdh�ZE d�didj�ZF d�dkdl�ZG d�dmdn�ZH d�dodp�ZI d�dqdr�ZJd�dsdt�ZKd�dudv�ZLd�dwdx�ZMd�dydz�ZNd�d{d|�ZOd�d}d~�ZPd�dd��ZQ d�d�d��ZRd�d�d��ZSd�d�d��ZT d�d�d��ZU d�d�d��ZV d�d�d��ZW d�d�d��ZXd�d�d��ZY d�d�d��ZZ d�d�d��Z[ d�d�d��Z\ d�d�d��Z] d�d�d��Z^ d�d�d��Z_ d�d�d��Z` d�d�d��Za d�d�d��Zb d�d�d��Zc d�d�d��Zd d�d�d��Zed�d�d��Zfd�d�d��Zgd�d�d��Zhd�d�d��Zi d�d�d��ZjdS )�aF Connection module for Amazon IAM .. versionadded:: 2014.7.0 :configuration: 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 at: .. code-block:: text 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 iam.keyid: GKTADJGHEIQSXMKKRBJ08H iam.key: askdjghsdfjkghWupUjasdflkdfklgjsdfjajkghs iam.region: 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 :depends: boto � N)�OrderedDict�boto�boto3TFc C s t jjjdd�S )z, Only load if boto libraries exist. F)Zcheck_boto3)�salt�utils�versionsZcheck_boto_reqs� r r �I/opt/saltstack/salt/lib/python3.10/site-packages/salt/modules/boto_iam.py�__virtual__C s r c C s t r td tdtd� d S d S )Nzboto.assign_funcs�iam)�pack)�HAS_BOTO� __utils__�__name__Z__salt__)�optsr r r �__init__J s �r c C �: t ||||d�}z|�| � W dS tjjy Y dS w )z� Check to see if an instance profile exists. CLI Example: .. code-block:: bash salt myminion boto_iam.instance_profile_exists myiprofile ��region�key�keyid�profileTF)� _get_connZget_instance_profiler � exception�BotoServerError��namer r r r �connr r r �instance_profile_existsO s �r c C s� t ||||d�}t| ||||�rdS z|�| � t�d| � W dS tjjy@ } zt�|� t� d| � W Y d}~dS d}~ww )z� Create an instance profile. CLI Example: .. code-block:: bash salt myminion boto_iam.create_instance_profile myiprofile r TzCreated %s instance profile.z%Failed to create %s instance profile.NF) r r �create_instance_profile�log�infor r r �debug�error�r r r r r r �er r r r d s � ��r c C � t ||||d�}t| ||||�sdS z|�| � t�d| � W dS tjjy@ } zt�|� t� d| � W Y d}~dS d}~ww )z� Delete an instance profile. CLI Example: .. code-block:: bash salt myminion boto_iam.delete_instance_profile myiprofile r TzDeleted %s instance profile.z%Failed to delete %s instance profile.NF) r r �delete_instance_profiler r! r r r r"