@@ -55,6 +55,14 @@ func GetenvWithDefault(key string, defaultValue string) string {
55
55
return envValue
56
56
}
57
57
58
+ func GetFunctionName () string {
59
+ defaultValue := "function"
60
+ if GetenvWithDefault ("AWS_LAMBDA_RIE_INCONSISTENT_BEHAVIOUR" , "TRUE" ) == "TRUE" {
61
+ defaultValue = "test_function"
62
+ }
63
+ return GetenvWithDefault ("AWS_LAMBDA_FUNCTION_NAME" , defaultValue )
64
+ }
65
+
58
66
func printEndReports (invokeId string , initDuration string , memorySize string , invokeStart time.Time , timeoutDuration time.Duration ) {
59
67
// Calcuation invoke duration
60
68
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
118
126
invokeStart := time .Now ()
119
127
invokePayload := & interop.Invoke {
120
128
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 ( )),
122
130
TraceID : r .Header .Get ("X-Amzn-Trace-Id" ),
123
131
LambdaSegmentID : r .Header .Get ("X-Amzn-Segment-Id" ),
124
132
Payload : bytes .NewReader (bodyBytes ),
@@ -198,7 +206,7 @@ func InitHandler(sandbox Sandbox, functionVersion string, timeout int64, bs inte
198
206
additionalFunctionEnvironmentVariables ["AWS_LAMBDA_LOG_STREAM_NAME" ] = "$LATEST"
199
207
additionalFunctionEnvironmentVariables ["AWS_LAMBDA_FUNCTION_VERSION" ] = "$LATEST"
200
208
additionalFunctionEnvironmentVariables ["AWS_LAMBDA_FUNCTION_MEMORY_SIZE" ] = "3008"
201
- additionalFunctionEnvironmentVariables ["AWS_LAMBDA_FUNCTION_NAME" ] = "test_function"
209
+ additionalFunctionEnvironmentVariables ["AWS_LAMBDA_FUNCTION_NAME" ] = GetFunctionName ()
202
210
203
211
// Forward Env Vars from the running system (container) to what the function can view. Without this, Env Vars will
204
212
// not be viewable when the function runs.
@@ -216,7 +224,7 @@ func InitHandler(sandbox Sandbox, functionVersion string, timeout int64, bs inte
216
224
AwsSecret : os .Getenv ("AWS_SECRET_ACCESS_KEY" ),
217
225
AwsSession : os .Getenv ("AWS_SESSION_TOKEN" ),
218
226
XRayDaemonAddress : "0.0.0.0:0" , // TODO
219
- FunctionName : GetenvWithDefault ( "AWS_LAMBDA_FUNCTION_NAME" , "test_function" ),
227
+ FunctionName : GetFunctionName ( ),
220
228
FunctionVersion : functionVersion ,
221
229
RuntimeInfo : interop.RuntimeInfo {
222
230
ImageJSON : "{}" ,
0 commit comments