Handling various endpoints for AWS API gateway stages

I want to be able to change the endpoint defined in each API Gateway method so that the staging environment called "Dev" points to my internal Dev API and Prod, which will naturally point to my API.

Currently I would have to manually change each method and then deploy it to the prod stag, but now, to do any testing, I would have to change them again for the dev stage.

I am promoting with a DNS switch to move Dev to Prod, but future development still requires a change for each method.

Example:

I have a resource called User and GET Method that maps to an endpoint (HTTP Proxy) -> http://dev.mytestapp.com/api/v1/user

Then I deploy a scene called Dev - the Dev phase gives me the url to call this resource eg. https://xxxxobl.execute-api.us-east-1.amazonaws.com/dev/user

Now I'm testing and it works as expected, so I want to move this to production stage by simply naming the scene. When I use prod my call url is now https://xxxxobl.execute-api.us-east-1.amazonaws.com/prod/user

but the problem is that the API still maps to the http://dev.mytestapp.com/api/v1/user endpoint and not something like http://prod.mytestapp.com/api/v1/user

So my scene and url have changed, but the actual API that is being called is hardcoded for dev.

Any ideas? Thanks to

+3


source to share


1 answer


You can use stage variables to route endpoints to different APIs. This page shows you how to set up a stage variable for an http proxy. You can also use scene variables for lambda functions.



+6


source







All Articles