I'm deploying an application to AWS Lambda using the serverless framwework. My application is served by a single Lambda which is why I pass through the request path using {proxy+}:
functions:
app:
runtime: go1.x
handler: bin/lambda
events:
- http:
path: /{proxy+}
method: any
Now, I'd like to use a custom authorizer Lambda to protect a certain portion of my application (think everything /admin/). I thought I could just add another event definition that uses the authorizer like this:
functions:
app:
runtime: go1.x
handler: bin/lambda
events:
- http:
path: /admin/{proxy+}
method: any
authorizer:
name: authorizer
resultTtlInSeconds: 0
identitySource: method.request.header.Authorization
- http:
path: /{proxy+}
method: any
yet this has no effect at all. If I apply my authorizer to the root level proxy, it will be applied as expected, so the authorizer itself works as expected.
How can I define my routes in such a scenario? Do I need to use different Lambdas or is there something I am missing?