File: //opt/saltstack/salt/lib/python3.10/site-packages/salt/modules/__pycache__/boto_iam.cpython-310.pyc
o
�N�gu. � @ s� d Z ddlZddlZddlZddlZddlZddlm m
Z
ddlZz&ddlZddl
Z
ddlZddlZe�d��ej� e�d��ej� dZW n eyT dZY nw e�e�Zdd� Zd d
� Zd�dd�Zd�d
d�Zd�dd�Zd�dd�Zd�dd�Zd�dd�Z d�dd�Zd�dd�Z d�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/d0�Z+ d�d1d2�Z,d�d4d5�Z- d�d6d7�Z. d�d8d9�Z/d�d:d;�Z0d�d<d=�Z1 d�d>d?�Z2d�d@dA�Z3d�dBdC�Z4 d�dDdE�Z5d�dFdG�Z6 d�dHdI�Z7d�dJdK�Z8 d�dLdM�Z9d�dNdO�Z:dPdQ� Z; d�dRdS�Z< d�dTdU�Z=d�dVdW�Z> d�dXdY�Z? d�dZd[�Z@ d�d\d]�ZA d�d^d_�ZBd�d`da�ZCd�dbdc�ZDd�ddde�ZEd�dfdg�ZF d�dhdi�ZG d�djdk�ZH d�dldm�ZI d�dndo�ZJ d�dpdq�ZKd�drds�ZLd�dtdu�ZMd�dvdw�ZNd�dxdy�ZOd�dzd{�ZPd�d|d}�ZQd�d~d�ZR d�d�d��ZSd�d�d��ZTd�d�d��ZU d�d�d��ZV d�d�d��ZW d�d�d��ZX d�d�d��ZYd�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��Ze d�d�d��Zfd�d�d��Zgd�d�d��Zhd�d�d��Zid�d�d��Zj d�d�d��ZkdS )�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�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! r"