@@ -39,6 +39,14 @@ func GetenvWithDefault(key string, defaultValue string) string {
3939 return envValue
4040}
4141
42+ func GetFunctionName () string {
43+ defaultValue := "function"
44+ if GetenvWithDefault ("AWS_LAMBDA_RIE_INCONSISTENT_BEHAVIOUR" , "TRUE" ) == "TRUE" {
45+ defaultValue = "test_function"
46+ }
47+ return GetenvWithDefault ("AWS_LAMBDA_FUNCTION_NAME" , defaultValue )
48+ }
49+
4250func printEndReports (invokeId string , initDuration string , memorySize string , invokeStart time.Time , timeoutDuration time.Duration ) {
4351 // Calcuation invoke duration
4452 invokeDuration := math .Min (float64 (time .Now ().Sub (invokeStart ).Nanoseconds ()),
@@ -95,7 +103,7 @@ func InvokeHandler(w http.ResponseWriter, r *http.Request, sandbox Sandbox) {
95103 invokeStart := time .Now ()
96104 invokePayload := & interop.Invoke {
97105 ID : uuid .New ().String (),
98- InvokedFunctionArn : fmt .Sprintf ("arn:aws:lambda:us-east-1:012345678912:function:%s" , GetenvWithDefault ( "AWS_LAMBDA_FUNCTION_NAME" , "test_function" )),
106+ InvokedFunctionArn : fmt .Sprintf ("arn:aws:lambda:us-east-1:012345678912:function:%s" , GetFunctionName ( )),
99107 TraceID : r .Header .Get ("X-Amzn-Trace-Id" ),
100108 LambdaSegmentID : r .Header .Get ("X-Amzn-Segment-Id" ),
101109 Payload : bytes .NewReader (bodyBytes ),
@@ -175,7 +183,7 @@ func InitHandler(sandbox Sandbox, functionVersion string, timeout int64) (time.T
175183 additionalFunctionEnvironmentVariables ["AWS_LAMBDA_LOG_STREAM_NAME" ] = "$LATEST"
176184 additionalFunctionEnvironmentVariables ["AWS_LAMBDA_FUNCTION_VERSION" ] = "$LATEST"
177185 additionalFunctionEnvironmentVariables ["AWS_LAMBDA_FUNCTION_MEMORY_SIZE" ] = "3008"
178- additionalFunctionEnvironmentVariables ["AWS_LAMBDA_FUNCTION_NAME" ] = "test_function"
186+ additionalFunctionEnvironmentVariables ["AWS_LAMBDA_FUNCTION_NAME" ] = GetFunctionName ()
179187
180188 // Forward Env Vars from the running system (container) to what the function can view. Without this, Env Vars will
181189 // not be viewable when the function runs.
@@ -194,7 +202,7 @@ func InitHandler(sandbox Sandbox, functionVersion string, timeout int64) (time.T
194202 AwsSecret : os .Getenv ("AWS_SECRET_ACCESS_KEY" ),
195203 AwsSession : os .Getenv ("AWS_SESSION_TOKEN" ),
196204 XRayDaemonAddress : "0.0.0.0:0" , // TODO
197- FunctionName : GetenvWithDefault ( "AWS_LAMBDA_FUNCTION_NAME" , "test_function" ),
205+ FunctionName : GetFunctionName ( ),
198206 FunctionVersion : functionVersion ,
199207
200208 CustomerEnvironmentVariables : additionalFunctionEnvironmentVariables ,
0 commit comments