1

Is it possible to have AWS's API gateway route based on query string parameters?

So for example:

api.com/stuff?version=1.0

will route to:

https://endpoint.com/mystuff

and

api.com/stuff?version=2.0

will route to:

https://endpoint.com:8080/mystuff

So far I haven't seen anything for this. I can send custom query string parameters along to my endpoints, but I don't seem to be able actually to do anything with them. If it's not possible, have requests been made for this? I can do this through lambda but I would really like to make sure this can't be done through AWS API Gateway first.

2 Answers 2

1

You cannot route based on your query parameters, (but it is possible to do the other way around although seems out of your interest).

You can pick "Use Lambda Proxy integration" option and in your method integration request.

Then, in your lambda you use

#python
event['queryStringParameters'] 

to access you query string parameters to do whatever you like.

Sign up to request clarification or add additional context in comments.

1 Comment

Dang. Alright, then that's what I will have to do. Thanks for the link and example.
0

No, unfortunately you cannot route the requests base on route parameters. I'll suggest to use the API Gateway stages instead. You can deploy multiple versions of the same API and differentiate them base on the root part of the path

https://domaincom/v1/....
https://domaincom/v2/...

1 Comment

Please share the documentation source on this to find more details. I assume: docs.aws.amazon.com/apigateway/latest/developerguide/… and docs.aws.amazon.com/apigateway/latest/developerguide/…

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.