Articles → AWS → Use AWS API Gateway Stage Variables To Call Specific Lambda Aliases

Use AWS API Gateway Stage Variables To Call Specific Lambda Aliases






Create A Lambda Function




Picture showing creating a lambda function in AWS console



Create The Lambda Function Alias




Picture showing an alias is created in lambda function



Create The Staging Variable




Picture showing the stage variables section for creating the stage variable




Picture showing the add stage variable button for adding the stage variable




Picture showing adding the stage variable




Picture showing the stage variables are added



Specifying The Staging Variable In API Gateway




${stageVariables.[staging_variable_name]}


Picture showing specifying the stage variable in the API gateway




Picture showing the CLI command to grant permission for using the stage variable





Executing Script On CLI




aws lambda add-permission --function-name "arn:aws:lambda:ap-south-1:462618770999:function:lambafunc:myalias" --source-arn "arn:aws:execute-api:ap-south-1:462618770999:iv8s88eaw7/*/GET/" --principal apigateway.amazonaws.com --statement-id 0c3f20ef-7652-411c-b82c-8ca69d0fbf70 --action lambda:InvokeFunction


Picture showing the execution of CLI command for granting permission for stage variable



Output




Picture showing the output of using stage variables to call specific lambda alias





Posted By  -  Karan Gupta
 
Posted On  -  Thursday, February 15, 2024

Query/Feedback


Your Email Id
 
Subject
 
Query/FeedbackCharacters remaining 250