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

Invoke Lambda via Http API inside Lambda Test Tool #1343

Open
1 of 2 tasks
ggaller opened this issue Oct 25, 2022 · 8 comments
Open
1 of 2 tasks

Invoke Lambda via Http API inside Lambda Test Tool #1343

ggaller opened this issue Oct 25, 2022 · 8 comments
Labels
feature-request A feature should be added or improved. module/lambda-test-tool p2 This is a standard priority issue queued

Comments

@ggaller
Copy link

ggaller commented Oct 25, 2022

Describe the feature

Adding http API to Lambda Test Tool as another way to call the function, along with web interface and CLI.

Use Case

In our games we build the server part on the Lambda function. With HTTP endpoint we could write a mock client and connect to the function running from the IDE with the possibility of debugging. It would be a normal local server listening on localhost.

Proposed Solution

I prepared a simple example that works. This is a controller with route to execute endpoint. It used injected LocalLambdaOptions and select default LambdaConfigInfo from it. Right now only payload is passed, but maybe we need to extend the api to be able to specify the function that we need to execute.

Other Information

No response

Acknowledgements

  • I may be able to implement this feature request
  • This feature might incur a breaking change

AWS .NET SDK and/or Package version used

Targeted .NET Platform

.NET 6

Operating System and version

Windows, Linux, MacOS

@ggaller ggaller added feature-request A feature should be added or improved. needs-triage This issue or PR still needs to be triaged. labels Oct 25, 2022
@ashishdhingra
Copy link
Contributor

@ggaller Thanks for submitting the feature request. This appears to be duplicate of #1279 (which is also reviewed by the team). Please review and confirm if this ticket could be closed as duplicate.

@ashishdhingra ashishdhingra added response-requested Waiting on additional info and feedback. Will move to close soon in 7 days. and removed needs-triage This issue or PR still needs to be triaged. labels Oct 25, 2022
@ggaller
Copy link
Author

ggaller commented Oct 26, 2022

Hi @ashishdhingra!
I looked at the #1279 and it seems to be a similar, but much more complex.
I know that the AWS team often implements services with partially overlapping functionality to better meet customer needs and maybe this is the case))
My solution serves to support compatibility with Lambda Invoke API no more and no less.
By adding a controller with these endpoints:

[HttpPost("execute")]
public async Task<IActionResult> ExecuteFunction()
{...}

[HttpPost("execute/{functionName}")]
[HttpPost("2015-03-31/functions/{functionName}/invocations")]
public async Task<object> ExecuteFunction(string functionName)
{...}

Lambda Test Tool will be support for the standard lambda client from the AWS SDK like this:

var client = new AmazonLambdaClient(new AmazonLambdaConfig
{
    EndpointProvider = new StaticEndpointProvider("http://localhost:5050/invokeapi/")
});

With support of transferring not only payload, but also logs (LogType.Tail) and errors similar like we get response from AWS.

What do you think of this approach?

Code is ready and I could have a PR ready tomorrow.

@github-actions github-actions bot removed the response-requested Waiting on additional info and feedback. Will move to close soon in 7 days. label Oct 27, 2022
@ashishdhingra
Copy link
Contributor

@ggaller Thanks for your response. Feel free to submit the PR which could be reviewed by the team.

@ggaller
Copy link
Author

ggaller commented Oct 28, 2022

@ashishdhingra PR #1349 is ready and waiting for the team's decision.

@ggaller
Copy link
Author

ggaller commented Dec 9, 2022

Hi @ashishdhingra. Any chance that the team looks at this issue and related PR?

@ggaller
Copy link
Author

ggaller commented Jan 24, 2023

Hi @normj!
I really appreciate what you do for .NET and enjoy using your tools. I also realise that you have a lot of tasks, but maybe you can spare a few minutes for this issue and related PR.
This is a very simple but important functionality that practically blurs the line between classic server-side solutions and the Lambda-based solution for local development and debugging.
We are now in the process of deciding how we want to start using local debugging and sharing it with our partners. The alternatives are to release a nuget package with a fork of Lambda Test Tool or release a trimmed nuget package just for debugging, but I would really like to have a single Lambda Test Tool that could be developed by AWS and the community together.
I hope to hear from you and have a nice day!

@ashishdhingra ashishdhingra added queued p2 This is a standard priority issue and removed needs-review labels Mar 3, 2023
@jeroenvervaeke
Copy link

Hi @ggaller,
Thank you for your contribution.
I have one small remark, but besides that it looks good to me.

@ggaller
Copy link
Author

ggaller commented Mar 15, 2023

Hi @jeroenvervaeke,
Thank you for your review.
Added fix by your comments

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request A feature should be added or improved. module/lambda-test-tool p2 This is a standard priority issue queued
Projects
None yet
Development

No branches or pull requests

3 participants