By using AWS re:Post, you agree to the Terms of Use
/Can't select a stage when setting up routes/

Can't select a stage when setting up routes

0

I have an API gateway set up with a custom domain attached to it. The custom domain setup looks like this:

API: TulipPager
Stage: v1
Path: tulip/v1
Default endpoint: Enabled

In the API gateway configuraiton, I have two stages created: v1 and v2. As it is set up now, when I go to:

https://mycustom.domain.com/tulip/v1/test

I get a response - it works!

Now, what I want to do next is to set up different routes for stage v1 and v2. Really, the table is basically the same but it has to point to different integrations (a v1 lambda and a v2 lambda).

My question is this: when I go into the console > API Gateway > Routes for this API, there's a drop-down menu for selecting the stage, but it's grayed out. I can't figure out how to have separate routes for stage v1 and stage v2.

Can somebody explain why the stages drop-down menu would be grayed out even though I have two stages defined? Does it matter that both those stages are on auto-deploy? (I tried it both ways and it didn't seem to).

The drop-down is grayed out at the Integrations configuration page as well. In fact, that's where I really care about it. I actually want the same routes for the entire API, but I want it to pick different functions depending on the stage. That's how I'm planning on supporting different versions of the API.

2 Answers
1
Accepted Answer

There is only one API definition that can be deployed to multiple stages. You change the definition and then you deploy. You can't really change the API that is deployed, unless you deploy again.

To achieve what you want, you need to use stage variables. So you will create a variable and in each stage you will give it a different name. The integration will use the stage variable as part of the definition. For example, you can have a stage variable called functionName. In stage v1 the value will be Function1. in stage v2 the value will be Function2. In the integration configuration you will use ${stageVariables.functioName} in place of the function name. You can find more information here.

EXPERT
answered a month ago
0

Thanks! I had read the documentation about this when I posed the question, but what what misled me was the dropdown at the very top of the Routes and Integrations screens in the console. They appear to let you select a stage for a set of routes or integrations, but the drop-down is grayed out. I'm not sure why they're there, and thought perhaps there was something I was missing to enable them.

I understand what you are saying about stage variables. I'll do that.

answered a month ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions