Skip to content

feat(proxy): abstract lambda runtime api proxy #669

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

Open
wants to merge 14 commits into
base: main
Choose a base branch
from

Conversation

duncanista
Copy link
Contributor

@duncanista duncanista commented May 1, 2025

What?

Abstracts the concept of the proxy from the Lambda Web Adapter implementation.
This will unlock the usage of ASM.

How?

Using axum crate, we create a new server proxy with specific routes from the Lambda Runtime API which we are interested in proxying.

Motivation

ASM and SVLS-6760

@duncanista duncanista requested a review from a team as a code owner May 1, 2025 22:38
impl Interceptor {
pub fn new(
config: Arc<Config>,
aws_config: &AwsConfig,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the aws config can also be removed

what is needed is only a proxy uri and a boolean for lwa

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually we need the following:

  1. AWS_LWA_LAMBDA_RUNTIME_API value
  2. AWS_LAMBDA_RUNTIME_API value

I can just send them instead of the whole config, but no matter what, this would increase the amount of fields in the state, and copying the AwsConfig struct isn't that expensive. I could also just make the config an Arc a reference if that's cleaner, reducing allocations.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I might have spread out the comments in the code:

it is a matter of abstraction and decoupling.
The code of the proxy/intercept should accept a socket and a uri. It should not care about which socket is lwa and which uri is in the config. And especially it could be not tightly coupled with the datadog configs.

The start method could simply get the 2 strings that are needed once, and never changed, and disregard the rest of the configs.
So any future change and refactor in the config won't affect most of this code

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand where you're coming from to remove the coupling.

Yet I think for configuration it should be OK, this proxy's sole purpose is to work with the AWS Lambda Runtime API and/or LWA.

I think I've removed so far the config field. I don't think the start should accept a socket/uri, this is a datadog proxy, it should remain coupled with the datadog configuration, we are eventually gonna need to use the configuration for appsec, so I don't think its bad that we have it as is.

Any change/refactor in the config should actually affect the code, we want to ensure everything works here, and not just where it's being called, that's how I see it, so far, only 2 products are (will) using it: LWA - AppSec

@duncanista duncanista force-pushed the jordan.gonzalez/proxy/abstract-lambda-runtime-api-proxy branch from a6d432b to c26ee6d Compare May 6, 2025 15:44
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

Successfully merging this pull request may close these issues.

3 participants