Add RestAPI stage variables support
Since I started working on #1467 I occasionally run into something since those authorizers interact with so many things.
I wanted to write tests for authorization with stage variables, but I haven't found any means of setting those, so I think this is a missing feature.
My proposition is to get those through config.json with the key stage_variables that would behave the same as environment_variables (could be global and per stage) and user would be able to define his variables there.
From what I see the websockets have a bit different method for putting stage variables in so it could be a different feature-request
Thanks for the suggestion. Could you give a specific example of what types of things you would put in stage variables? What's an example of how you'd use an authorizer with stage vars? Just trying to understand the feature better and what types of functionality this would enable.
Hi @jamesls
Although I like the environment variables approach and use them a lot, I can see someone feeling reluctant to place something that would concern the whole API stage in environment variable and having to use os.getenv() to access it. I am actually wondering if I saw this feature in the beginings of using Chalice would I place some of the environmental variables in the apigateway stage
The AWS documentation specify some use cases https://docs.aws.amazon.com/apigateway/latest/developerguide/stage-variables.html here and in the context of usecase in authorizers, I see that this can be used as a feature flag inside of the authorizer.
To be honest my main rationale for this feature was that I saw the feature that is available in API Gateway, noticed that this is missing in Chalice, checked up the code only to find that it is not difficult or breaking thing to implement and people could potentially use it instead of environment variable. Request object in local already has stage_vars attribute which is hardcoded to {} so why not add functionality to it :)
Hi @jamesls I don't know if you've seen the answer yet. Yesterday I was looking through Issues and found out this issue is a duplicate: https://github.com/aws/chalice/issues/728 And there is PR for allowing stage variables (so they must be using it in production and testing with hardcoded local): https://github.com/aws/chalice/pull/982
@ivandjuricic @jamesls could this be merged and updated?