Exemple #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
Exemple #2
0
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