File manager - Edit - /opt/saltstack/salt/lib/python3.10/site-packages/salt/modules/__pycache__/boto_s3_bucket.cpython-310.pyc
Back
o ;j( � @ sP d Z ddlZddlZddlZddlZddlmZ e�e �Z zddlZddlZddl mZ e�d��ej� dZW n eyC dZY nw dd � Zd d� ZdBdd �Z dCdd�Z dDdd�Z dEdd�ZdBdd�Z dEdd�ZdBdd�Z dFdd�Z dGdd�Z dCdd�ZdBd d!�Z dBd"d#�Z dFd$d%�Z! dFd&d'�Z"dBd(d)�Z#dBd*d+�Z$ dBd,d-�Z%dBd.d/�Z&dBd0d1�Z' dEd2d3�Z( dHd4d5�Z)dBd6d7�Z* dBd8d9�Z+dBd:d;�Z,dBd<d=�Z-dBd>d?�Z.dBd@dA�Z/dS )Ia6 Connection module for Amazon S3 Buckets .. 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 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 s3.keyid: GKTADJGHEIQSXMKKRBJ08H s3.key: askdjghsdfjkghWupUjasdflkdfklgjsdfjajkghs A region may also be specified in the configuration: .. code-block:: yaml s3.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 � N)�SaltInvocationError)�ClientError�boto3TFc C s t jjjdd�S )zg Only load if boto libraries exist and if boto libraries are greater than a given version. z1.2.1)Z boto3_ver)�salt�utilsZversionsZcheck_boto_reqs� r r �O/opt/saltstack/salt/lib/python3.10/site-packages/salt/modules/boto_s3_bucket.py�__virtual__Q s r c C s t rtd td� d S d S )Nzboto3.assign_funcsZs3)�HAS_BOTO� __utils__�__name__)�optsr r r �__init__\ s �r c C s� zt ||||d�}|j| d�}ddiW S tyE } z&|j�di ��d�dkr1ddiW Y d }~S td |�}d|iW Y d }~S d }~ww )a Given a bucket name, check to see if the given bucket exists. Returns True if the given bucket exists and returns False if the given bucket does not exist. CLI Example: .. code-block:: bash salt myminion boto_s3_bucket.exists mybucket ��region�key�keyid�profile��Bucket�existsT�Error�CodeZ404FN�boto3.get_error�error)� _get_connZhead_bucketr �response�getr ) r r r r r �conn�buckets�e�errr r r r a s ��r c C s� zWt || | |d�}i } dD ]}t� | durtt� | �| |<