Api Gateway can't invoke Lambda function

[亡魂溺海] 提交于 2019-12-04 13:57:14
JBaczuk

Web Console Method:

Thanks to this mate I found a quick fix:

Go into the web console and select

The resource method > Integration Request > Pencil next to Lambda Function > Check mark next to lambda function (don't change the name)

A popup window should warn that you are granting permissions to the API to execute the lambda function.


API Method:

Also, thanks to Richard Downer for this code explanation:

A resource policy is different from an IAM Policy, setting the IAM policy will not work.

You need to use the Add-LMPermission api call after creation of Write-AGIntegration.

Here is an example:

Add-LMPermission -FunctionName myfunction -Action lambda:InvokeFunction -Principal apigateway.amazonaws.com -SourceArn arn:aws:execute-api:us-west-2:IAMAccountNumber:*/*/POST/apiendpoint -StatementId description

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!