Lambda event validation best practice?

0

I want to create a standard way to validate the content of the event as soon as I can. I want to validate that keys are present and that they have the correct data type.

Is there a standard way to do this with Python?

Mick B
已提問 1 年前檢視次數 1130 次
1 個回答
1
已接受的答案

Hi Mick,

there are several ways in which you can implement a schema validation. For example, if you receive requests to your AWS Lambda functions via an Amazon API Gateway, you can use request validation (https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-method-request-validation.html).

Lambda Powertools for Python has a validation feature as well (https://awslabs.github.io/aws-lambda-powertools-python/2.16.2/utilities/validation/).

But you could also use any of several Python libraries to implement validation in your functions directly, like jsonschema (https://python-jsonschema.readthedocs.io/en/latest/validate/)

profile pictureAWS
專家
已回答 1 年前

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南