def get_acl(bucket: Dict, client: botocore.client.BaseClient) -> Optional[str]: """ Gets the S3 bucket ACL. Returns ACL string """ try: acl = client.get_bucket_acl(Bucket=bucket['Name']) except ClientError as e: if "AccessDenied" in e.args[0]: logger.warning( "Failed to retrieve S3 bucket {} ACL - Access Denied".format( bucket['Name'])) return None elif "NoSuchBucket" in e.args[0]: logger.warning( "Failed to retrieve S3 bucket {} ACL - No Such Bucket".format( bucket['Name'])) return None elif "AllAccessDisabled" in e.args[0]: logger.warning( "Failed to retrieve S3 bucket {} ACL - Bucket is disabled". format(bucket['Name'])) return None elif "EndpointConnectionError" in e.args[0]: logger.warning( "Failed to retrieve S3 bucket {} ACL - EndpointConnectionError" .format(bucket['Name'])) return None else: raise return acl
def get_acl(bucket: Dict, client: botocore.client.BaseClient) -> Optional[str]: """ Gets the S3 bucket ACL. Returns ACL string """ try: acl = client.get_bucket_acl(Bucket=bucket['Name']) except ClientError as e: if _is_common_exception(e, bucket): return None else: raise return acl
def get_acl(bucket: Dict, client: botocore.client.BaseClient) -> Optional[Dict]: """ Gets the S3 bucket ACL. """ acl = None try: acl = client.get_bucket_acl(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 ACL for {bucket['Name']} - Could not connect to the endpoint URL", ) return acl