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
질문됨 일 년 전1126회 조회
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
전문가
답변함 일 년 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠