コード例 #1
0
def get_encryption(bucket: Dict, client: botocore.client.BaseClient) -> Optional[str]:
    """
    Gets the S3 bucket default encryption configuration. Returns encryption configuration or None if not enabled
    """
    try:
        encryption = client.get_bucket_encryption(Bucket=bucket['Name'])
    except ClientError as e:
        if "ServerSideEncryptionConfigurationNotFoundError" in e.args[0]:
            return None
        elif _is_common_exception(e, bucket):
            return None
        else:
            raise
    return encryption
コード例 #2
0
ファイル: s3.py プロジェクト: rajkrishnamurthy/cartography
def get_encryption(bucket: Dict,
                   client: botocore.client.BaseClient) -> Optional[Dict]:
    """
    Gets the S3 bucket default encryption configuration.
    """
    encryption = None
    try:
        encryption = client.get_bucket_encryption(Bucket=bucket['Name'])
    except ClientError as e:
        if _is_common_exception(e, bucket):
            pass
        else:
            raise
    except EndpointConnectionError:
        logger.warning(
            f"Failed to retrieve S3 bucket encryption for {bucket['Name']} - Could not connect to the endpoint URL",
        )
    return encryption