title: How can I grant permission to API Gateway to invoke lambda functions through CloudFormation?
body: <p>I've been all over the web searching for an answer to this.</p>
  
  <p>Essentially, we're spinning up an API using Swagger, which is awesome and works great, but one thing doesn't work... When we make a call to an Endpoint, we get a 500 error (it's not a 500 error that we're providing either it's one from AWS). The error states "Execution failed due to configuration error: Invalid permissions on Lambda function" (<a href="https://youtu.be/H4LM_jw5zzs" rel="noreferrer">https://youtu.be/H4LM_jw5zzs</a> &lt;- This is a video, from another user, of the error I'm getting).</p>
  
  <p>I've gone down many ratholes, and have found an answer... It involves using the AWS CLI and looks a bit like this:</p>
  
  <pre><code>aws lambda add-permission \
  --function-name FUNCTION_NAME \
  --statement-id STATEMENT_ID \
  --action lambda:InvokeFunction \
  --principal apigateway.amazonaws.com \
  --source-arn "arn:aws:execute-api:us-east-1:ACCOUNT_ID:API_ID/*/METHOD/ENDPOINT"
  </code></pre>
  
  <p>This is great and all, but we are using CloudFormation to spin up everything and we want this to be automated. Is there an easier way to go about this? Is there something in CloudFormation that will give us the resource policy that we need?</p>
  
  <p>I'm hitting a bit of a wall with this, but I've been working on it for a few hours today and it's a bit of a blocker for our API release, so any help would be much appreciated. :)</p>