`AWS_LAMBDA_HTTP_IGNORE_STAGE_IN_PATH` does not ignore stage in API Gateway V2 (HTTP)
Maintainer thường phản hồi trong vòng 11 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 48/100
Hướng nghiên cứu
Bắt đầu bằng cách chạy bản tái hiện Axum và API Gateway V2 được cung cấp với AWS_LAMBDA_HTTP_IGNORE_STAGE_IN_PATH được bật, sau đó lần theo cách xử lý RequestContext::ApiGatewayV2 và biến môi trường. Hoàn thành khi yêu cầu /v1/not-staged đến được route /not-staged, trong khi route có stage vẫn tiếp tục hoạt động.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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?
- Ngôn ngữ chính
- Rust
- Star
- 3.6k
- Fork
- 398
- Merge trung bình
- 11 ngày 2 giờ
- Pull request đã merge (30 ngày)
- 4
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của aws/aws-lambda-rust-runtime
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 74/100
aws/aws-lambda-rust-runtime#1165 ·
Maintainer thường phản hồi trong vòng 11 ngày
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 68/100
aws/aws-lambda-rust-runtime#1161 ·
Maintainer thường phản hồi trong vòng 11 ngày
-
Add Lambda-Runtime-Invocation-Id header support for cross-wiring protectionCó thể làm lại được @darklight3it đã nhận 69 ngày trước và không có pull request nào đang mở. Đang mở
aws/aws-lambda-rust-runtime#1155 · 1 reaction · 1 người được giao ·
Maintainer thường phản hồi trong vòng 11 ngày
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 48/100
aws/aws-lambda-rust-runtime#1131 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 11 ngày
-
experimental lambda battery packĐang mở
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 30/100
aws/aws-lambda-rust-runtime#1128 · 1 bình luận · 1 reaction ·
Maintainer thường phản hồi trong vòng 11 ngày
Tất cả issue của aws/aws-lambda-rust-runtime
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 1 ngày
-
install: root SSH tmpfiles.d drop-in is labeled etc_runtime_t instead of etc_tCó thể đã có người làm @andrewdunndev đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
Maintainer thường phản hồi trong vòng 1 ngày
-
[Misdetection] `text/tab-separated-values` file misdetected as `text/tsv`Có thể đã có người làm @bact đã nhận hôm nay. Đang mởmisdetection needs triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
Maintainer thường phản hồi trong vòng 1 ngày
-
C-bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 2 ngày