Reputation: 93
I have setup a Amazon Lambda function that has different Aliases for development, test and production and an API gateway that has several stages pointing to the respective Alias versions.
Now I want to access a database table and obviously each Alias should access it's own table. In the documentation I couldn't find a possibility to pass an Alias specific configuration to my function. Is there a best practice for this?
Upvotes: 2
Views: 774
Reputation: 200476
Setup Stage Variables in API Gateway, and add something like the following to your mapping template(s) to pass those stage variables to the Lambda functions.
"stage-variables" : {
#foreach($key in $stageVariables.keySet())
"$key" : "$util.escapeJavaScript($stageVariables.get($key))"
#if($foreach.hasNext),#end
#end
}
The Lambda functions can then pull things like DB table names from the event object.
Upvotes: 1