@@ -55,6 +55,14 @@ func GetenvWithDefault(key string, defaultValue string) string {
5555 return envValue
5656}
5757
58+ func GetFunctionName () string {
59+ defaultValue := "function"
60+ if GetenvWithDefault ("AWS_LAMBDA_RIE_DYNAMIC_FUNCTION_URL" , "FALSE" ) == "FALSE" {
61+ defaultValue = "test_function"
62+ }
63+ return GetenvWithDefault ("AWS_LAMBDA_FUNCTION_NAME" , defaultValue )
64+ }
65+
5866func printEndReports (invokeId string , initDuration string , memorySize string , invokeStart time.Time , timeoutDuration time.Duration ) {
5967 // Calcuation invoke duration
6068 invokeDuration := math .Min (float64 (time .Now ().Sub (invokeStart ).Nanoseconds ()),
@@ -118,7 +126,7 @@ func InvokeHandler(w http.ResponseWriter, r *http.Request, sandbox Sandbox, bs i
118126 invokeStart := time .Now ()
119127 invokePayload := & interop.Invoke {
120128 ID : uuid .New ().String (),
121- InvokedFunctionArn : fmt .Sprintf ("arn:aws:lambda:us-east-1:012345678912:function:%s" , GetenvWithDefault ( "AWS_LAMBDA_FUNCTION_NAME" , "test_function" )),
129+ InvokedFunctionArn : fmt .Sprintf ("arn:aws:lambda:us-east-1:012345678912:function:%s" , GetFunctionName ( )),
122130 TraceID : r .Header .Get ("X-Amzn-Trace-Id" ),
123131 LambdaSegmentID : r .Header .Get ("X-Amzn-Segment-Id" ),
124132 Payload : bytes .NewReader (bodyBytes ),
@@ -198,7 +206,7 @@ func InitHandler(sandbox Sandbox, functionVersion string, timeout int64, bs inte
198206 additionalFunctionEnvironmentVariables ["AWS_LAMBDA_LOG_STREAM_NAME" ] = "$LATEST"
199207 additionalFunctionEnvironmentVariables ["AWS_LAMBDA_FUNCTION_VERSION" ] = "$LATEST"
200208 additionalFunctionEnvironmentVariables ["AWS_LAMBDA_FUNCTION_MEMORY_SIZE" ] = "3008"
201- additionalFunctionEnvironmentVariables ["AWS_LAMBDA_FUNCTION_NAME" ] = "test_function"
209+ additionalFunctionEnvironmentVariables ["AWS_LAMBDA_FUNCTION_NAME" ] = GetFunctionName ()
202210
203211 // Forward Env Vars from the running system (container) to what the function can view. Without this, Env Vars will
204212 // not be viewable when the function runs.
@@ -216,7 +224,7 @@ func InitHandler(sandbox Sandbox, functionVersion string, timeout int64, bs inte
216224 AwsSecret : os .Getenv ("AWS_SECRET_ACCESS_KEY" ),
217225 AwsSession : os .Getenv ("AWS_SESSION_TOKEN" ),
218226 XRayDaemonAddress : "0.0.0.0:0" , // TODO
219- FunctionName : GetenvWithDefault ( "AWS_LAMBDA_FUNCTION_NAME" , "test_function" ),
227+ FunctionName : GetFunctionName ( ),
220228 FunctionVersion : functionVersion ,
221229 RuntimeInfo : interop.RuntimeInfo {
222230 ImageJSON : "{}" ,
0 commit comments