dynamo.py 文件源码

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

项目:ebs_snapper 作者: rackerlabs 项目源码 文件源码
def get_configuration(context, installed_region, object_id, aws_account_id=None):
    """Retrieve configuration from DynamoDB and return single object"""
    if aws_account_id is None:
        aws_account_id = utils.get_owner_id(context)[0]

    dynamodb = boto3.resource('dynamodb', region_name=installed_region)
    table = dynamodb.Table('ebs_snapshot_configuration')

    expr = Key('aws_account_id').eq(aws_account_id) & Key('id').eq(object_id)
    results = table.query(KeyConditionExpression=expr)

    for item in results.get('Items', []):
        str_item = item.get('configuration', None)
        try:
            json_item = json.loads(str_item)
            return json_item
        except Exception as e:
            raise EbsSnapperError('error loading configuration', e)

    return None
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号