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.
# 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'})
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
how it should be done