Configures permissions for an API Gateway to invoke a Lambda function.

Terraform Template

resource "aws_api_gateway_rest_api" "MyDemoAPI" {
  description = "This is my API for demonstration purposes"
  name = "MyDemoAPI"
}

resource "aws_lambda_permission" "lambda_permission" {
  action = "lambda:InvokeFunction"
  function_name = "MyDemoFunction"
  principal = "apigateway.amazonaws.com"
  source_arn = "${aws_api_gateway_rest_api.MyDemoAPI.execution_arn}/*"
  statement_id = "AllowMyDemoAPIInvoke"
}