Я пытаюсь запросить свою таблицу Dynamodb с помощью запроса boto3 с помощью FilterExpression, но результаты не возвращаются, потому что имя атрибута, которое я sh фильтрую, имеет '. в этом. ExpressionAttributeNames, похоже, не работает с boto3.dynamodb.conditions.Attr, и я не могу найти в Интернете пример python кода аналогичного сценария.
kwargs = {'IndexName': constants.RESOURCE_TYPE_INDEX, 'KeyConditionExpression': Key(constants.RESOURCE_TYPE).eq(constants.AUTOSCALING_GROUP),
'FilterExpression': Attr('configuration.loadBalancerNames').contains(filter_value),
'ProjectionExpression': 'relationships, PRIMARY_KEY'}
print("Getting associations for: " + constants.AUTOSCALING_GROUP)
retry = True
while retry:
retry = False
try:
response = table.query(**kwargs)
except ClientError as e:
if e.response['Error']['Code'] == 'ProvisionedThroughputExceededException':
time.sleep(5)
retry = True
print("Retrying query")
else:
exception_type = str(e.__class__.__name__)
logger.error(
"Function: utilities.get_asg_records_for_lb_enrichment " + "Exception Type: " + exception_type + " Exception Message:" + str(e))
except Exception as e:
exception_type = str(e.__class__.__name__)
logger.error(
"Function: utilities.get_asg_records_for_lb_enrichment " + "Exception Type: " + exception_type + " Exception Message:" + str(e))
if response:
associations.extend(response.get('Items'))
if response.get('LastEvaluatedKey'):
kwargs['ExclusiveStartKey'] = response.get('LastEvaluatedKey')
retry = True
print("Last evaluated key found: " + str(response.get('LastEvaluatedKey')))