2
votes

I've read a lots of API versioning hints for integrating AWS API Gateway with Lambda functions. But most of them used the URL to provide the version number e.g. /v1/orders

But I do not want to use this pattern. Instead I'd like to evaluate the header information to retrieve the requested version.

What I want to do is the following:

  • configure API Gateway (via CloudFormation) in order to define only /orders
  • use request mapping to read a header 'version'
  • call a lambda function e.g. getOrders:v1 if 'version' header is set to 'v1'

Is this possible with AWS Api Gateway? Or is there a similar approach that doesn't use URL to distinguish between versions?

I saw a solution by using stage variables: https://dzone.com/articles/api-versioning-approach-with-aws-api-gateway

Regarding this approach: Is there an equivalent to ${stageVariables.v1fn} for headers? E.g. ${request.headers.version}?

1

1 Answers

0
votes

A possible solution would be to use a lambda which dispatches the request to the lambda in question, API Gateway unfortunately only supports one lambda per endpoint and method