3
votes

I have a Lambda with a DEV and PROD alias, and am trying to setup the API Endpoint on the Lambda to point to a PUT on a DEV and PROD stage of my API Gateway. I can successfully add and test the DEV/PUT endpoint, but when I try to add an endpoint on the PROD lambda, and select the PROD API stage, it won't let me choose the PUT method for the endpoint? I assume this is because I have the DEV/PUT already assigned? I can understand not letting one method point to multiple lambdas, but this is for two different stages? Am I doing this wrong?

1

1 Answers

2
votes

OK, so looks like this might just be a UI restriction. I was able to use the CLI to "aws lambda add-permission" for my API Endpoints, to each lambda function:alias combination which allows them to invoke the lambda functions.

eg.

aws lambda add-permission --function-name arn:aws:lambda:<REGION>:<ID>:function:<LAMBDA_NAME>:${stageVariables.lambdaAlias} --source-arn arn:aws:execute-api:<REGION>:<ID>:<API_ID>/*/GET/* --principal apigateway.amazonaws.com --statement-id <STATEMENT_ID> --action lambda:InvokeFunction

This was suggested by the UI when I edited the Integration Request on the API Gateway Method, and inserted the ${stageVariables.lambdaAlias}.