Skip to content

Fix default function name #49

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions cmd/aws-lambda-rie/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ func InvokeHandler(w http.ResponseWriter, r *http.Request, sandbox Sandbox) {
invokeStart := time.Now()
invokePayload := &interop.Invoke{
ID: uuid.New().String(),
InvokedFunctionArn: fmt.Sprintf("arn:aws:lambda:us-east-1:012345678912:function:%s", GetenvWithDefault("AWS_LAMBDA_FUNCTION_NAME", "test_function")),
InvokedFunctionArn: fmt.Sprintf("arn:aws:lambda:us-east-1:012345678912:function:%s", GetenvWithDefault("AWS_LAMBDA_FUNCTION_NAME", "function")),
TraceID: r.Header.Get("X-Amzn-Trace-Id"),
LambdaSegmentID: r.Header.Get("X-Amzn-Segment-Id"),
Payload: bytes.NewReader(bodyBytes),
Expand Down Expand Up @@ -175,7 +175,7 @@ func InitHandler(sandbox Sandbox, functionVersion string, timeout int64) (time.T
additionalFunctionEnvironmentVariables["AWS_LAMBDA_LOG_STREAM_NAME"] = "$LATEST"
additionalFunctionEnvironmentVariables["AWS_LAMBDA_FUNCTION_VERSION"] = "$LATEST"
additionalFunctionEnvironmentVariables["AWS_LAMBDA_FUNCTION_MEMORY_SIZE"] = "3008"
additionalFunctionEnvironmentVariables["AWS_LAMBDA_FUNCTION_NAME"] = "test_function"
additionalFunctionEnvironmentVariables["AWS_LAMBDA_FUNCTION_NAME"] = "function"

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

CustomerEnvironmentVariables: additionalFunctionEnvironmentVariables,
Expand Down
4 changes: 2 additions & 2 deletions test/integration/testdata/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ def check_env_var_handler(event, context):

def assert_env_var_is_overwritten(event, context):
print(os.environ.get("AWS_LAMBDA_FUNCTION_NAME"))
if os.environ.get("AWS_LAMBDA_FUNCTION_NAME") == "test_function":
if os.environ.get("AWS_LAMBDA_FUNCTION_NAME") == "function":
raise("Function name was not overwritten")
else:
return "My lambda ran succesfully"

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