aws / aws/aws-lambda-runtime-interface-emulator

Hardcoded function name

未關閉
#43 0 則留言 5 個 reaction 已指派 0 人 在 GitHub 檢視
enhancement
主要語言
Go
星號
1.1k
分支
118
平均合併
42 分鐘
30 天內合併 PR
2

描述

I'm not sure if this is a bug or a feature (request). I'll let someone else decide which it is.

The [Lambda invoke API docs](https://docs.aws.amazon.com/lambda/latest/dg/API_Invoke.html#API_Invoke_RequestSyntax) say the endpoint path should be `/2015-03-31/functions/FunctionName/invocations` where `FunctionName` is the name of the function being invoked.

The [RIE web server hardcods the function name to `function`](https://github.com/aws/aws-lambda-runtime-interface-emulator/blob/ce45546/cmd/aws-lambda-rie/http.go#L18). When invoking a function by calling the documented `curl` call `curl -XPOST "http://localhost:9000/2015-03-31/functions/function/invocations" -d '{}'` everything works great.

If someone combines a container based Lambda using the RIE and the Step Function Local and the step function contains a different function name, say `myFunction` they could easily lose an afternoon debugging their stuff. Step Function Local logs an exception based on the 404 response, but the RIE logs show no requests being received. After checking the Step Function Local config docs, reviewing the step function multiple times, reviewing the Lambda API docs and busting out wireshark the dev may pick through the RIE code. Eventually they would discover the cause of this bug. Less than a minute after changing the value of the Lambda ARN in their step function, everything works.

Rather than forcing devs to use a fixed name in their step function, I propose that if the `AWS_LAMBDA_FUNCTION_NAME` environment variable is set, then that is the value used in the endpoint path. If the environment variable isn't present then `function` is used as the default value. This might save some poor developers many hours of swearing at their code.

貢獻指南

開啟貢獻指南

研究方向

從 cmd/aws-lambda-rie/http.go 開始,RIE Web 伺服器在其中將函式名稱硬編碼,並將端點行為與 Lambda Invoke API 文件進行比較。確認 AWS_LAMBDA_FUNCTION_NAME 應如何影響端點,並確認該變數不存在時預設值仍為 function;當設定的名稱和預設名稱都能透過文件所述的呼叫請求正常運作時,即表示完成。

由索引模型根據 Issue 內容生成。

評估

技術堆疊
aws, go
領域
api, cloud
Issue 類型
缺陷
難度
2/5
預估耗時
1-3 小時
活躍度
停滯
描述清晰度
描述清楚
新手友好度
45/100

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。