0
votes

I have been putting together and deploying Lambda functions using Apex and the functions, where I have been using GET method through AWS API Gateway are working fine.

I now need to create an API to call into a Lambda function using POST and pass in a JSON object. To get the basics of POST working I created a simple Lambda function that just does the following

console.log("!!!!!!! Received request");
callback(null, {data: "Success"});
return;

When I call this Lambda function using a GET method from API Gateway and test the API, it works fine - the API Gateway Test mechanism gives the "success" message while "Received Request" is logged in a successful call in CloudWatch.

However when I use the POST request to call the same Lambda function from API Gateway I get the following

"message": "Internal server error"

And I also see "Execution failed due to configuration error: Invalid permissions on Lambda function"

So what I am wondering is whether the role by which Lambda functions are called require any additional privileges when that function is invoked through a POST method. If so what is that privilege that I need to assign to the role being used?

Thanks, Sanjay.

2

2 Answers

0
votes

If you want to call POST method through API gateway level, that post method you have to deploy. Go to AWS API Gateway console. then select your POST API name and on the top of the grid (screen) you will find a drop down called Actions, there one option called deploy. That you have to select then only your POST API will work.

0
votes

API Gateway needs permissions to invoke your Lambda function. It prompts you to add the permission automatically if you configure your API via the web console, and the Lambda function is not specified with a stage variable.

So if you're using a tool like CloudFormation or Swagger import to create or update your APIs, or the Lambda function is specified with a stage variable, you'll need issue a aws lambda add-permission command manually to set the permission.

See these posts for more details:

Lambda function -> Api Gateway stage variable permission manually

AWS API Gatewat with proxy Lambda: Invalid permissions on Lambda function