現在apiからlambdaの関数を動かしてdynamodbからデータを取得してapiのデプライからurlを叩いてデータを表示するプログラムを作っているのですがlambdaのテストのところで積んでいます。関数が悪いのか、jsonファイルなのか、データベースなのかわかりません....教えてください...
python
1import boto3 2 3dynamodb = boto3.resource('dynamodb') 4table = dynamodb.Table('t_watersencer') 5 6def get_person(id): 7 response = table.get_item( 8 Key={ 9 'timestamp': id 10 } 11 ) 12 return response['Item'] 13def lambda_handler(event, context): 14 person = get_person('timestamp') 15 return person 16
//json "device": "water_hign", "timestamp": "123", "watertemp": "10", "bettery": "11", "waterlevel": "12" }
//エラーメッセージ
{
"errorMessage": "An error occurred (ValidationException) when calling the GetItem operation: The provided key element does not match the schema",
"errorType": "ClientError",
"stackTrace": [
[
"/var/task/lambda_function.py",
14,
"lambda_handler",
"person = get_person('timestamp')"
],
[
"/var/task/lambda_function.py",
9,
"get_person",
"'timestamp': id"
],
[
"/var/runtime/boto3/resources/factory.py",
520,
"do_action",
"response = action(self, *args, **kwargs)"
],
[
"/var/runtime/boto3/resources/action.py",
83,
"call",
"response = getattr(parent.meta.client, operation_name)(**params)"
],
[
"/var/runtime/botocore/client.py",
314,
"_api_call",
"return self._make_api_call(operation_name, kwargs)"
],
[
"/var/runtime/botocore/client.py",
612,
"_make_api_call",
"raise error_class(parsed_response, operation_name)"
]
]
}