Serverless Framewokr で Python の Lambda 関数を作成していたら以下のエラーが発生した。
"errorMessage": "Bad handler 'lambda_handler': not enough values to unpack (expected 2, got 1)" "errorType": "Runtime.MalformedHandlerName"
ディレクトリ構造は以下の様な形にしていた。
./my-prj ┣ serverless.yml ┗ test.py
serverless.ymlをざっくり以下のようにしていた。
functions:
Test:
handler: test
description: test
test.pyのハンドラーを以下のようにしていた。
def lambda_handler(event, context):
...
これがダメだった模様。
実際にはモジュール名とハンドラー名に合わせて、serverless.ymlのhandlerを以下の様にする必要があった。
test.pyがモジュール、test.pyの中のlambda_handlerがハンドラーになる。
functions:
Test:
handler: test.lambda_handler
description: test