2025 06 03
Docker Image: public.ecr.aws/lambda/python:3.13
AWS Lambda をローカルで動作確認するために Docker でコンテナを作成し、そこに以下の実行用リクエストを送った際にエラーが発生した。
> curl -XPOST "http://localhost:9000/2015-03-31/functions/function/invocations" -d '{"payload":"hello world!"}'
Invoke-WebRequest : パラメーター名 'XPOST' に一致するパラメーターが見つかりません。
発生場所 行:1 文字:6
+ curl -XPOST "http://localhost:9000/2015-03-31/functions/function/invo ...
+ ~~~~~~
+ CategoryInfo : InvalidArgument: (:) [Invoke-WebRequest]、ParameterBindingException
+ FullyQualifiedErrorId : NamedParameterNotFound,Microsoft.PowerShell.Commands.InvokeWebRequestCommand
これは curl コマンドが Powershell において Invoke-WebRequest
のエイリアスとして設定されているため。
> Get-Alias curl
CommandType Name Version Source
----------- ---- ------- ------
Alias curl -> Invoke-WebRequest
これを避けるためには curl.exe
のように実行ファイルを指定してやればよい。
ただし変更しても別件で以下のようなエラーが発生する。
> curl.exe -XPOST "http://localhost:9000/2015-03-31/functions/function/invocations" -d '{"payload":"hello world!"}'
{"errorMessage": "Unable to unmarshal input: Expecting property name enclosed in double quotes: line 1 column 2 (char 1)", "errorType": "Runtime.UnmarshalError", "requestId": "a01dfb32-68a7-40ea-8017-d323b7693d40", "stackTrace": []}
以下のようにすればエラーが発生しない。原因はよくわからない。