Hello there, when creating a route_key
beginning with ANY
and ending with {proxy+}
I can create a Lambda function to which all subroutes will point, here’s a snippet :
module "http_lambda_foo_any" {
source = "./lambda"
api_id = aws_apigatewayv2_api.http.id
route_key = "ANY /foo/{proxy+}"
function_name = "http_foo_any"
environment = var.environment
lambda_bundle_path = var.lambda_bundle_path
lambda_handler = "src/http/foo/foo_any.handler"
For example, this matches GET /foo/
, GET /foo/{id}
, POST /foo/
, DELETE /foo/{id}
, etc.
But, CORS won’t work in this case, while it works when not using ANY
and {proxy+}
.
CORS configuration looks like this (values filled, of course) :
name = "${var.environment}-foo-http"
protocol_type = "HTTP"
target = ""
cors_configuration {
allow_origins = [""]
allow_methods = [""]
allow_headers = [""]
expose_headers = [""]
}
}
Here’s the documentation I used to do this :
- https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-develop-routes.html
- https://www.1strategy.com/blog/2017/06/06/how-to-use-amazon-api-gateway-proxy/
Any ideas ?
Thanks.