@@ -39,6 +39,14 @@ func GetenvWithDefault(key string, defaultValue string) string {
39
39
return envValue
40
40
}
41
41
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
+
42
50
func printEndReports (invokeId string , initDuration string , memorySize string , invokeStart time.Time , timeoutDuration time.Duration ) {
43
51
// Calcuation invoke duration
44
52
invokeDuration := math .Min (float64 (time .Now ().Sub (invokeStart ).Nanoseconds ()),
@@ -95,7 +103,7 @@ func InvokeHandler(w http.ResponseWriter, r *http.Request, sandbox Sandbox) {
95
103
invokeStart := time .Now ()
96
104
invokePayload := & interop.Invoke {
97
105
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 ( )),
99
107
TraceID : r .Header .Get ("X-Amzn-Trace-Id" ),
100
108
LambdaSegmentID : r .Header .Get ("X-Amzn-Segment-Id" ),
101
109
Payload : bytes .NewReader (bodyBytes ),
@@ -175,7 +183,7 @@ func InitHandler(sandbox Sandbox, functionVersion string, timeout int64) (time.T
175
183
additionalFunctionEnvironmentVariables ["AWS_LAMBDA_LOG_STREAM_NAME" ] = "$LATEST"
176
184
additionalFunctionEnvironmentVariables ["AWS_LAMBDA_FUNCTION_VERSION" ] = "$LATEST"
177
185
additionalFunctionEnvironmentVariables ["AWS_LAMBDA_FUNCTION_MEMORY_SIZE" ] = "3008"
178
- additionalFunctionEnvironmentVariables ["AWS_LAMBDA_FUNCTION_NAME" ] = "test_function"
186
+ additionalFunctionEnvironmentVariables ["AWS_LAMBDA_FUNCTION_NAME" ] = GetFunctionName ()
179
187
180
188
// Forward Env Vars from the running system (container) to what the function can view. Without this, Env Vars will
181
189
// not be viewable when the function runs.
@@ -194,7 +202,7 @@ func InitHandler(sandbox Sandbox, functionVersion string, timeout int64) (time.T
194
202
AwsSecret : os .Getenv ("AWS_SECRET_ACCESS_KEY" ),
195
203
AwsSession : os .Getenv ("AWS_SESSION_TOKEN" ),
196
204
XRayDaemonAddress : "0.0.0.0:0" , // TODO
197
- FunctionName : GetenvWithDefault ( "AWS_LAMBDA_FUNCTION_NAME" , "test_function" ),
205
+ FunctionName : GetFunctionName ( ),
198
206
FunctionVersion : functionVersion ,
199
207
200
208
CustomerEnvironmentVariables : additionalFunctionEnvironmentVariables ,
0 commit comments