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

feature: proxy requests back through tunnel to originate from lambda execution environment #68

Open
rogerchi opened this issue Oct 3, 2024 · 4 comments

Comments

@rogerchi
Copy link
Contributor

rogerchi commented Oct 3, 2024

I wonder if it would be possible to proxy requests originating from the local debug environment back through the IOT tunnel and originate them from the lambda execution environment? A few different use cases we have for this:

  • We use the Lambda Secrets Extension which runs a local listener in the lambda environment to provide cached secrets
  • We have various Lambdas that are deployed inside VPCs so that they can connect to resources inside private networks

reference: https://www.frodehus.dev/debugging-web-requests-using-mitmproxy-wsl-and-vscode/

@ServerlessLife
Copy link
Owner

That is a brilliant idea. 💡

I am not sure how hard it would be to implement that. For HTTP traffic, it would probably be easier, but for TCP (like SQL database connection), it could be a bit challenging. I will explore it further.

@ServerlessLife
Copy link
Owner

I found quite some npm libraries that can intercept either HTTP or TCP requests or both:
https://www.npmjs.com/package/mitm
https://www.npmjs.com/package/@mswjs/interceptors
https://www.npmjs.com/package/node-request-interceptor
https://www.npmjs.com/package/@gr2m/net-interceptor

Using them would probably not be that hard to implement the functionality. The Lambda handler runs in a Node Worket Thread, so it is isolated, and any HTTP/TCP interception would probably not cause other issues on the Lambda Live Debugger.

@rogerchi
Copy link
Contributor Author

rogerchi commented Oct 4, 2024

mitm looks perfect

@ServerlessLife
Copy link
Owner

I played with this for some time and think it's doable.
The mitm library looks like the way to go, although it is not well maintained. I instantly found this issue: moll/node-mitm#42 (comment), which blocked me for some time. But I found an easy workaround.

The TCP also intercepts HTTP connections, so there would be one solution for both.

I see the most value when using SQL database or Redis in VPC. Resolving issues with any other connection within VPC or using the Lambda Secrets Extension would also be very valuable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants