-
Notifications
You must be signed in to change notification settings - Fork 533
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
fea: add aws-lambda-alb
support
#2914
base: v2
Are you sure you want to change the base?
Conversation
WHAT? Add additional tests to `aws-lambda` runtime. WHY? Improve the thoroughness and accuracy of the tests. HOW? `pnpm build && pnpm test`
WHAT? Add support for ALB lambda function targets. WHY? `ALBEvent` is similar to `APIGatewayProxyEvent`. However, it has key differences such as: - Query string parameters are not URL-decoded automatically. - The events either have `headers`/`queryStringParameters` or `multiValueHeaders`/`multiValueQueryStringParameters`, but not both. - Headers without values are removed from the event's input. Without this change, using `nitro` with Lambda + ALB yields unexpected behaviors like double URL encoding. HOW? `pnpm build && pnpm test`
WHAT? Update `aws-lambda` preset's documentation to clearly indicate which event types are supported. WHY? Avoid confusion from users when trying to use an unsupported event type.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note: Tests are based on the behaviors observed here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When work finished, would be nice if we can also setup for nitro-deploys to make sure preset works also in actual environment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When work finished, would be nice if we can also setup for nitro-deploys to make sure preset works also in actual environment.
I'm not sure how to action this since there doesn't seem to be any workflow in place that deploys to AWS (AWS account, credentials and infra would would be a pre-req). Also, it seems all deployments except alwaysdata.yml are currently disabled.
Thanks for PR. Considering several differences, i think it would be nicer if we develop a standalone subpreset + entry such as |
aws-lambda-alb
support
Thanks for the reply @pi0!
Just to confirm, do you mean something like the following? Update: nitro/src/presets/aws-lambda/types.ts Lines 1 to 3 in f982f99
to: export type AwsLambdaOptions =
| {
// backwards compatibility, the presence of `type` overrides this
streaming?: boolean;
}
| {
/**
* The Lambda function type:
*
* - `alb`: An ALB Lambda target group.
* - `api-gateway`: An API Gateway REST API Lambda proxy integration, HTTP API Lambda integration, or Lambda function URL.
* - `function-url`: A synonym of `api-gateway`.
* - `function-url-stream`: A Lambda function URL with response streaming.
*
* @default "api-gateway"
*/
type?: "api-gateway" | "alb" | "function-url" | "function-url-stream";
}; And update: nitro/src/presets/aws-lambda/preset.ts Lines 10 to 16 in f982f99
to: hooks: {
"rollup:before": (nitro, rollupConfig) => {
if ("type" in nitro.options.awsLambda) {
if (nitro.options.awsLambda.type === "alb") {
(rollupConfig.input as string) += "-alb";
} else if (nitro.options.awsLambda.type === "function-url-stream") {
(rollupConfig.input as string) += "-streaming";
}
} else if (nitro.options.awsLambda.streaming) {
(rollupConfig.input as string) += "-streaming";
}
},
}, |
I mean making new variant / export in presets (similar to cloudflare/) |
π Linked issue
#2072
β Type of change
π Description
WHAT?
Add support for ALB lambda function targets.
WHY?
ALBEvent
is similar toAPIGatewayProxyEvent
. However, it has key differences such as:headers
/queryStringParameters
ormultiValueHeaders
/multiValueQueryStringParameters
, butnot both.
Without this change, using
nitro
with Lambda + ALB yields unexpected behaviors like double URL encoding.RESOLVES?
#2072
π Checklist