Boto Scan Filterexpression:参数的类型无效
问题描述:
我正在尝试使用下面的代码,但我无法使其工作。它不断给我一个关于过滤器表达式是错误类型的错误消息,即使我正在执行the documentation中的完成操作。我能做些什么来解决这个问题?Boto Scan Filterexpression:参数的类型无效
def EndpointDeleted(event):
endpoint = event['Attributes']['EndpointArn']
if('EndpointArn' in event['Attributes']):
client = boto3.client('dynamodb')
response = client.scan(
TableName='sniffergps-mobilehub-812282467-Users',
Select='ALL_ATTRIBUTES',
FilterExpression=Attr('Endpoints').contains(endpoint)
)
return response
,但我得到一个错误,指出该过滤器表达式的类型不正确。我有以下的进口消息: import boto3 from boto3.dynamodb.conditions import Key from boto3.dynamodb.conditions import Attr
错误消息:
{
"errorMessage": "Parameter validation failed:\nInvalid type for parameter FilterExpression, value: <boto3.dynamodb.conditions.Contains object at 0x7fdca25e0b38>, type: <class 'boto3.dynamodb.conditions.Contains'>, valid types: <class 'str'>",
"errorType": "ParamValidationError",
"stackTrace": [
[
"/var/task/lambda_function.py",
13,
"lambda_handler",
"return EndpointDeleted(event)"
],
[
"/var/task/lambda_function.py",
24,
"EndpointDeleted",
"FilterExpression=Attr('Endpoints').contains(endpoint)"
],
[
"/var/runtime/botocore/client.py",
312,
"_api_call",
"return self._make_api_call(operation_name, kwargs)"
],
[
"/var/runtime/botocore/client.py",
575,
"_make_api_call",
"api_params, operation_model, context=request_context)"
],
[
"/var/runtime/botocore/client.py",
630,
"_convert_to_request_dict",
"api_params, operation_model)"
],
[
"/var/runtime/botocore/validate.py",
291,
"serialize_to_request",
"raise ParamValidationError(report=report.generate_report())"
]
]
}