2
votes

I can use stage variables to execute different lamdbas but it looks like you can also have mapping templates read them and do stuff based on their valued: https://docs.aws.amazon.com/apigateway/latest/developerguide/stage-variables.html

But Im using the lambda proxy integration so i dont have mapping templates. Is there a way to pass stage configuration variables to a lambda with the rpoxy integration?

Right now Im just doing this to use a stage variable to point to the right lambda for the stage: Fn::Sub: arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/arn:aws:lambda:${AWS::Region}:${AWS::AccountId}:function:${!stageVariables.LambdaFunctionName}/invocations

1

1 Answers

3
votes

All the defined stage variables are passed in the stageVariables field of the event parameter in the lambda function:

import json
def handler(event, context):
    return {
        "statusCode": 200,
        "headers": {"Content-Type": "application/json"},
        "body": json.dumps(event['stageVariables'])
    }