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
评论列表
文章目录