title: AWS API Gateway with proxy Lambda: Invalid permissions on Lambda function
body: <p>I am using AWS API Gateway with a proxy Lambda, when the name of the lambda function is coming as a stage variable. Meaning I have a single API integration which connects to appropriate lambda according to the deployed stage.
  See the general idea here:
  <a href="https://i.stack.imgur.com/kPjI2.png" rel="noreferrer"><img src="https://i.stack.imgur.com/kPjI2.png" alt="enter image description here"></a></p>
  
  <p>When I test one of my stages (called: "staging") everything works fine, but when testing the other stage ("production") I get the error "Execution failed due to configuration error: Invalid permissions on Lambda function".</p>
  
  <p>Things I already tested and verified:<br>
  1. Both lambdas which should be invoked by the API work well and as expected when tested from the Lambda dashboard.<br>
  2. I've made sure (many times) that I've given permission to the API gateway to invoke my lambda function (i.e. executed "aws lambda add-permission..."). I've validated the policy afterwards many times (i.e. executed "aws lambda get-policy...").</p>
  
  <p>Any idea what else I can check ? What I might have forgotten here ?
  Thanks.  </p>
  
  <p><a href="https://i.stack.imgur.com/vQfrV.png" rel="noreferrer"><img src="https://i.stack.imgur.com/vQfrV.png" alt="enter image description here"></a></p>