__init__.py 文件源码

python
阅读 24 收藏 0 点赞 0 评论 0

项目:Falco 作者: VCCRI 项目源码 文件源码
def is_valid_s3_bucket(s3_string):
    """
    Determine if the input string starts with a valid s3 bucket name
    :param s3_string: an aws s3 address (e.g. s3://mybucket/other...)
    :return: True if the s3_string contains a valid bucket name
    """
    client = boto3.client('s3')
    # only applies to s3 - so ignore otherwise
    if s3_string[0:5] != 's3://':
        return False
    # get the bucket name
    bucket = s3_string[5:].strip('/').split('/')[0]
    if not bucket:
        return False
    # see if bucket exists
    try:
        client.list_objects(Bucket=bucket)
    except:
        return False

    return True
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号