0

I have a Python application running on AWS Lambda and exposed through AWS API Gateway. In my handler class, I have defined an endpoint as @api.route(/api/v1/dep/<path:data>), and in my Terraform configuration file, specifically the api-gateway-vars.tf, I have defined the lambda path as

"/api/v1/dep/{proxy+}": 
{
"methods" : ["get"], "requireApiKey" : "false", "authorizer" : "false",
"lambda" : "something", "lambdaEnvVars" : {}
}

The problem I am facing is that API Gateway only accepts the path without a trailing slash (/) and returns a 404 error when I try to access the same endpoint with the trailing slash. However, I want API Gateway to handle both cases, allowing the endpoint to be accessed with or without the trailing slash. For eg. /api/v1/dep/top and /api/v1/dep/top/

Could anyone please share what is missing here?

  • Allegedly `/users` and `/users/` are two distinct identifiers. More discussion [here](https://stackoverflow.com/questions/61547014/restful-uri-trailing-slash-or-no-trailing-slash). – jarmod Jun 14 '23 at 16:57
  • @jarmod Interesting! Seems Terraform considers considers it as same because it was complaining when I defined these two paths, with and without trailing slash- ```Duplicate method 'GET' on resource at path '/api/v1/dep/top'``` – continuousLearner Jun 14 '23 at 21:19

0 Answers0