Skip to content

Commit ebc933d

Browse files
committed
Fix default function name
As noted in aws#46, the function name is derived from the URL used to invoke it. The emulator uses `function` in the API endpoint, but the `AWS_LAMBDA_FUNCTION_NAME` environment variable is set to `test_function`. This is an inconsistency between the emulator and the AWS environment.
1 parent 3567179 commit ebc933d

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

Diff for: cmd/aws-lambda-rie/handlers.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ func InvokeHandler(w http.ResponseWriter, r *http.Request, sandbox Sandbox) {
9595
invokeStart := time.Now()
9696
invokePayload := &interop.Invoke{
9797
ID: uuid.New().String(),
98-
InvokedFunctionArn: fmt.Sprintf("arn:aws:lambda:us-east-1:012345678912:function:%s", GetenvWithDefault("AWS_LAMBDA_FUNCTION_NAME", "test_function")),
98+
InvokedFunctionArn: fmt.Sprintf("arn:aws:lambda:us-east-1:012345678912:function:%s", GetenvWithDefault("AWS_LAMBDA_FUNCTION_NAME", "function")),
9999
TraceID: r.Header.Get("X-Amzn-Trace-Id"),
100100
LambdaSegmentID: r.Header.Get("X-Amzn-Segment-Id"),
101101
Payload: bytes.NewReader(bodyBytes),
@@ -175,7 +175,7 @@ func InitHandler(sandbox Sandbox, functionVersion string, timeout int64) (time.T
175175
additionalFunctionEnvironmentVariables["AWS_LAMBDA_LOG_STREAM_NAME"] = "$LATEST"
176176
additionalFunctionEnvironmentVariables["AWS_LAMBDA_FUNCTION_VERSION"] = "$LATEST"
177177
additionalFunctionEnvironmentVariables["AWS_LAMBDA_FUNCTION_MEMORY_SIZE"] = "3008"
178-
additionalFunctionEnvironmentVariables["AWS_LAMBDA_FUNCTION_NAME"] = "test_function"
178+
additionalFunctionEnvironmentVariables["AWS_LAMBDA_FUNCTION_NAME"] = "function"
179179

180180
// Forward Env Vars from the running system (container) to what the function can view. Without this, Env Vars will
181181
// not be viewable when the function runs.
@@ -194,7 +194,7 @@ func InitHandler(sandbox Sandbox, functionVersion string, timeout int64) (time.T
194194
AwsSecret: os.Getenv("AWS_SECRET_ACCESS_KEY"),
195195
AwsSession: os.Getenv("AWS_SESSION_TOKEN"),
196196
XRayDaemonAddress: "0.0.0.0:0", // TODO
197-
FunctionName: GetenvWithDefault("AWS_LAMBDA_FUNCTION_NAME", "test_function"),
197+
FunctionName: GetenvWithDefault("AWS_LAMBDA_FUNCTION_NAME", "function"),
198198
FunctionVersion: functionVersion,
199199

200200
CustomerEnvironmentVariables: additionalFunctionEnvironmentVariables,

Diff for: test/integration/testdata/main.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,13 @@ def check_env_var_handler(event, context):
2525

2626
def assert_env_var_is_overwritten(event, context):
2727
print(os.environ.get("AWS_LAMBDA_FUNCTION_NAME"))
28-
if os.environ.get("AWS_LAMBDA_FUNCTION_NAME") == "test_function":
28+
if os.environ.get("AWS_LAMBDA_FUNCTION_NAME") == "function":
2929
raise("Function name was not overwritten")
3030
else:
3131
return "My lambda ran succesfully"
3232

3333
def assert_lambda_arn_in_context(event, context):
34-
if context.invoked_function_arn == f"arn:aws:lambda:us-east-1:012345678912:function:{os.environ.get('AWS_LAMBDA_FUNCTION_NAME', 'test_function')}":
34+
if context.invoked_function_arn == f"arn:aws:lambda:us-east-1:012345678912:function:{os.environ.get('AWS_LAMBDA_FUNCTION_NAME', 'function')}":
3535
return "My lambda ran succesfully"
3636
else:
3737
raise("Function Arn was not there")

0 commit comments

Comments
 (0)