`AWS_LAMBDA_HTTP_IGNORE_STAGE_IN_PATH` does not ignore stage in API Gateway V2 (HTTP)
维护者通常 11 天内回复
还没有人认领这个 Issue。
评估
调研方向
首先,在启用 AWS_LAMBDA_HTTP_IGNORE_STAGE_IN_PATH 的情况下运行所提供的 Axum 和 API Gateway V2 复现,然后跟踪对 RequestContext::ApiGatewayV2 和环境变量的处理。完成的标准是 /v1/not-staged 请求能够到达 /not-staged 路由,同时带 stage 的路由仍能正常工作。
由索引模型根据 Issue 内容生成。
描述
The AWS_LAMBDA_HTTP_IGNORE_STAGE_IN_PATH env variable doesn't seem to work on API Gateway V2 (HTTP).
Example:
use axum::{response::Json, routing::get, Router};
use lambda_http::request::RequestContext::ApiGatewayV2;
use lambda_http::{run, tracing, Error};
use serde_json::{json, Value};
// Sample middleware that logs the request id
async fn mw_sample(
req: axum::extract::Request,
next: axum::middleware::Next,
) -> impl axum::response::IntoResponse {
let context = req
.extensions()
.get::<lambda_http::request::RequestContext>();
if let Some(ApiGatewayV2(ctx)) = context {
tracing::info!("RequestId = {:?}", ctx);
}
next.run(req).await
}
async fn handler_sample() -> Json<Value> {
Json(json!({ "echo": "hello" }))
}
#[tokio::main]
async fn main() -> Result<(), Error> {
std::env::set_var("AWS_LAMBDA_HTTP_IGNORE_STAGE_IN_PATH", "true"); // ignore stages in routing
tracing::init_default_subscriber();
let app = Router::new()
.route("/not-staged", get(handler_sample)) // stage not specified, not working
.route("/v1/staged", get(handler_sample)) // stage specified, working
.layer(axum::middleware::from_fn(mw_sample));
run(app).await
}
Cargo.toml:
[package]
name = "test"
version = "0.1.0"
edition = "2021"
[dependencies]
axum = "0.7.5"
lambda_http = "0.13.0"
serde = "1.0.209"
serde_json = "1.0.127"
tokio = { version = "1", features = ["macros"] }
I will attach my Terraform code as well:
module "api_lambda_function" {
source = "terraform-aws-modules/lambda/aws"
function_name = "some-api"
runtime = "provided.al2023"
architectures = ["arm64"]
timeout = 15
create_package = false
// Change path to your bin
local_existing_package = "../../../target/lambda/simple2/bootstrap.zip"
handler = "bootstrap"
create_current_version_allowed_triggers = false
allowed_triggers = {
AllowExecutionFromAPIGateway = {
service = "apigateway"
source_arn = "${aws_apigatewayv2_api.main.execution_arn}/*"
}
}
}
resource "aws_apigatewayv2_api" "main" {
name = "${local.name_prefix}-api"
protocol_type = "HTTP"
}
resource "aws_apigatewayv2_stage" "v1" {
api_id = aws_apigatewayv2_api.main.id
name = "v1"
auto_deploy = true
}
resource "aws_apigatewayv2_integration" "api_lambda" {
api_id = aws_apigatewayv2_api.main.id
integration_type = "AWS_PROXY"
integration_method = "POST"
integration_uri = module.api_lambda_function.lambda_function_arn
payload_format_version = "2.0"
depends_on = [module.api_lambda_function.lambda_function_arn]
}
resource "aws_apigatewayv2_route" "get_1" {
api_id = aws_apigatewayv2_api.main.id
route_key = "GET /not-staged"
target = "integrations/${aws_apigatewayv2_integration.api_lambda.id}"
}
resource "aws_apigatewayv2_route" "get_2" {
api_id = aws_apigatewayv2_api.main.id
route_key = "GET /staged"
target = "integrations/${aws_apigatewayv2_integration.api_lambda.id}"
}
Build with:
cargo lambda build --release --arm64 --output-format zip
And then apply Terraform.
When calling a /v1/staged route, response is returned:
But not for /v1/not-staged - response is 404:
Am I doing something wrong?
Can someone please suggest how to debug this issue?
- 主要语言
- Rust
- 星标
- 3.6k
- 派生
- 398
- 平均合并
- 7 天 4 小时
- 30 天内合并 PR
- 3
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
aws/aws-lambda-rust-runtime 的其他 Issue
-
[lambda_http] Fallible response body panics during buffered conversion instead of propagating the body error可能已有人在做 @IamPritamAcharya 于 34 天前认领。 未关闭
难度 3/5 1-2 天 新手友好度 74/100
aws/aws-lambda-rust-runtime#1165 ·
维护者通常 11 天内回复
-
SNS `Timestamp` doesn't round-trip: serialization drops `.000` subseconds, corrupting the signed string-to-sign可能已有人在做 @DebadityaHait 于 62 天前认领。 未关闭
难度 3/5 1-2 天 新手友好度 68/100
aws/aws-lambda-rust-runtime#1161 ·
维护者通常 11 天内回复
-
Add Lambda-Runtime-Invocation-Id header support for cross-wiring protection可能重新可做 @darklight3it 于 74 天前认领,目前没有进行中的 PR。 未关闭
aws/aws-lambda-rust-runtime#1155 · 1 个 reaction · 已指派 1 人 ·
维护者通常 11 天内回复
-
IoTCoreCustomAuthorizerResponse create invalid payalod可能已有人在做 @IamPritamAcharya 于 34 天前认领。 未关闭
难度 3/5 1-2 天 新手友好度 48/100
aws/aws-lambda-rust-runtime#1131 · 1 条评论 ·
维护者通常 11 天内回复
-
难度 5/5 一周以上 新手友好度 30/100
aws/aws-lambda-rust-runtime#1128 · 1 条评论 · 1 个 reaction ·
维护者通常 11 天内回复
查看 aws/aws-lambda-rust-runtime 的全部 Issue
相似的 Issue
-
awaiting-response bug needs-triage
难度 2/5 1-3 小时 新手友好度 72/100
维护者通常 3 天内回复
-
难度 2/5 1-3 小时 新手友好度 75/100
objectionary/sodg.rs#301 ·
-
难度 2/5 1-3 小时 新手友好度 62/100
HakanSeven12/OpenCADStudio#1706 · 1 条评论 ·
维护者通常 1 天内回复
-
[Bug] Completion info popup (.cm-completionInfo) ignores the configured editor font可能已有人在做 关联的 PR 仍在进行中或已合并。 未关闭bug user-priority/P2
难度 2/5 1-3 小时 新手友好度 62/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 65/100
rescript-lang/rescript#8765 ·
维护者通常 1 天内回复