Saasli / saasli-backend

Documentation
https://saasli.github.io/docs/
0 stars 0 forks source link

use Context stage to identify stage, not function name #38

Closed godd9170 closed 7 years ago

godd9170 commented 7 years ago

According to http://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-mapping-template-reference.html

There is actually a 'stage' attribute in the context of each lambda call. Instead of ripping apart the function name, would be much cleaner to use this.

How it's currently done here

        # Get the version of the api
        try:
            self.version = context.function_name.split('-')[1] #grab the stage version name from the function name
        except AttributeError, e:
            raise AWSError({'error' : 'Fatal Error'})

how it should be done

        # Get the version of the api
        try:
            self.version = context.stage #grab the stage version name from the function name
        except AttributeError, e:
            raise AWSError({'error' : 'Fatal Error'})
godd9170 commented 7 years ago

Unfortunately the 'Stage' is always $Latest in Serverless so this is no good :(