Skip to content
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

Hardcoded function name #43

Open
skwashd opened this issue Aug 8, 2021 · 0 comments
Open

Hardcoded function name #43

skwashd opened this issue Aug 8, 2021 · 0 comments
Labels
enhancement New feature or request

Comments

@skwashd
Copy link

skwashd commented Aug 8, 2021

I'm not sure if this is a bug or a feature (request). I'll let someone else decide which it is.

The Lambda invoke API docs say the endpoint path should be /2015-03-31/functions/FunctionName/invocations where FunctionName is the name of the function being invoked.

The RIE web server hardcods the function name to function. When invoking a function by calling the documented curl call curl -XPOST "http://localhost:9000/2015-03-31/functions/function/invocations" -d '{}' everything works great.

If someone combines a container based Lambda using the RIE and the Step Function Local and the step function contains a different function name, say myFunction they could easily lose an afternoon debugging their stuff. Step Function Local logs an exception based on the 404 response, but the RIE logs show no requests being received. After checking the Step Function Local config docs, reviewing the step function multiple times, reviewing the Lambda API docs and busting out wireshark the dev may pick through the RIE code. Eventually they would discover the cause of this bug. Less than a minute after changing the value of the Lambda ARN in their step function, everything works.

Rather than forcing devs to use a fixed name in their step function, I propose that if the AWS_LAMBDA_FUNCTION_NAME environment variable is set, then that is the value used in the endpoint path. If the environment variable isn't present then function is used as the default value. This might save some poor developers many hours of swearing at their code.

skwashd added a commit to skwashd/aws-lambda-runtime-interface-emulator that referenced this issue Sep 4, 2021
The API endpoint in Amazon's implementation of Lambda used the path
`/2015-03-31/functions/[func]/invocations` to invoke the function.
`[func]` the name of the function and is set as the value of the
`AWS_LAMBDA_FUNCTION_NAME` environment variable when the function
is executing on AWS.

The emulator uses a hard coded endpoint of
`/2015-03-31/functions/function/invocations`. This is even the case
when the `AWS_LAMBDA_FUNCTION_NAME` environment variable is set to
another value.

This patch changes the endpoint URL when the `AWS_LAMBDA_FUNCTION_NAME`
environment variable is set. In this case the invocation URL will
be `/2015-03-31/functions/${AWS_LAMBDA_FUNCTION_NAME}/invocations`.
When the environment variable isn't set, the current behaviour
persists and the function name is set to `function`.

The end result is the emulator behaviour is closer to the real
environment the functions execute in.

This PR fixes aws#43 I raised a few weeks ago.
skwashd added a commit to skwashd/aws-lambda-runtime-interface-emulator that referenced this issue Oct 4, 2021
The API endpoint in Amazon's implementation of Lambda used the path
`/2015-03-31/functions/[func]/invocations` to invoke the function.
`[func]` the name of the function and is set as the value of the
`AWS_LAMBDA_FUNCTION_NAME` environment variable when the function
is executing on AWS.

The emulator uses a hard coded endpoint of
`/2015-03-31/functions/function/invocations`. This is even the case
when the `AWS_LAMBDA_FUNCTION_NAME` environment variable is set to
another value.

This patch changes the endpoint URL when the `AWS_LAMBDA_FUNCTION_NAME`
environment variable is set. In this case the invocation URL will
be `/2015-03-31/functions/${AWS_LAMBDA_FUNCTION_NAME}/invocations`.
When the environment variable isn't set, the current behaviour
persists and the function name is set to `function`.

The end result is the emulator behaviour is closer to the real
environment the functions execute in.

This PR fixes aws#43 I raised a few weeks ago.
skwashd added a commit to skwashd/aws-lambda-runtime-interface-emulator that referenced this issue Oct 5, 2021
The API endpoint in Amazon's implementation of Lambda used the path
`/2015-03-31/functions/[func]/invocations` to invoke the function.
`[func]` the name of the function and is set as the value of the
`AWS_LAMBDA_FUNCTION_NAME` environment variable when the function
is executing on AWS.

The emulator uses a hard coded endpoint of
`/2015-03-31/functions/function/invocations`. This is even the case
when the `AWS_LAMBDA_FUNCTION_NAME` environment variable is set to
another value.

This patch changes the endpoint URL when the `AWS_LAMBDA_FUNCTION_NAME`
environment variable is set. In this case the invocation URL will
be `/2015-03-31/functions/${AWS_LAMBDA_FUNCTION_NAME}/invocations`.
When the environment variable isn't set, the current behaviour
persists and the function name is set to `function`.

The end result is the emulator behaviour is closer to the real
environment the functions execute in.

This PR fixes aws#43 I raised a few weeks ago.
skwashd added a commit to skwashd/aws-lambda-runtime-interface-emulator that referenced this issue Dec 28, 2021
The API endpoint in Amazon's implementation of Lambda used the path
`/2015-03-31/functions/[func]/invocations` to invoke the function.
`[func]` the name of the function and is set as the value of the
`AWS_LAMBDA_FUNCTION_NAME` environment variable when the function
is executing on AWS.

The emulator uses a hard coded endpoint of
`/2015-03-31/functions/function/invocations`. This is even the case
when the `AWS_LAMBDA_FUNCTION_NAME` environment variable is set to
another value.

This patch changes the endpoint URL when the `AWS_LAMBDA_FUNCTION_NAME`
environment variable is set. In this case the invocation URL will
be `/2015-03-31/functions/${AWS_LAMBDA_FUNCTION_NAME}/invocations`.
When the environment variable isn't set, the current behaviour
persists and the function name is set to `function`.

The end result is the emulator behaviour is closer to the real
environment the functions execute in.

This PR fixes aws#43 I raised a few weeks ago.
@ghost ghost added the enhancement New feature or request label Aug 17, 2022
skwashd added a commit to skwashd/aws-lambda-runtime-interface-emulator that referenced this issue Jul 9, 2024
The API endpoint in Amazon's implementation of Lambda used the path
`/2015-03-31/functions/[func]/invocations` to invoke the function.
`[func]` the name of the function and is set as the value of the
`AWS_LAMBDA_FUNCTION_NAME` environment variable when the function
is executing on AWS.

The emulator uses a hard coded endpoint of
`/2015-03-31/functions/function/invocations`. This is even the case
when the `AWS_LAMBDA_FUNCTION_NAME` environment variable is set to
another value.

This patch changes the endpoint URL when the `AWS_LAMBDA_FUNCTION_NAME`
environment variable is set. In this case the invocation URL will
be `/2015-03-31/functions/${AWS_LAMBDA_FUNCTION_NAME}/invocations`.
When the environment variable isn't set, the current behaviour
persists and the function name is set to `function`.

The end result is the emulator behaviour is closer to the real
environment the functions execute in.

This PR fixes aws#43 I raised a few weeks ago.
skwashd added a commit to skwashd/aws-lambda-runtime-interface-emulator that referenced this issue Jul 9, 2024
The API endpoint in Amazon's implementation of Lambda used the path
`/2015-03-31/functions/[func]/invocations` to invoke the function.
`[func]` the name of the function and is set as the value of the
`AWS_LAMBDA_FUNCTION_NAME` environment variable when the function
is executing on AWS.

The emulator uses a hard coded endpoint of
`/2015-03-31/functions/function/invocations`. This is even the case
when the `AWS_LAMBDA_FUNCTION_NAME` environment variable is set to
another value.

This patch changes the endpoint URL when the `AWS_LAMBDA_FUNCTION_NAME`
environment variable is set. In this case the invocation URL will
be `/2015-03-31/functions/${AWS_LAMBDA_FUNCTION_NAME}/invocations`.
When the environment variable isn't set, the current behaviour
persists and the function name is set to `function`.

The end result is the emulator behaviour is closer to the real
environment the functions execute in.

This PR fixes aws#43 I raised a few weeks ago.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant