首页 文章

Api Gateway无法调用Lambda函数

提问于
浏览
2

this tutorial on AWS之后,我在尝试通过Web控制台测试api时遇到了障碍(正如许多其他人所做的那样):

Thu Nov 10 22:54:48 UTC 2016 : Execution failed due to configuration error: Invalid permissions on Lambda function

我已经阅读了我能找到的SO和AWS论坛上的所有相关帖子,但无法弄清楚如何授予API网关调用Lambda函数的权限 .

1 回答

  • 7

    Web控制台方法:

    感谢this mate我发现了一个快速修复:

    进入Web控制台并选择

    资源方法>集成请求> Lambda函数旁边的铅笔> lambda函数旁边的复选标记(不要更改名称)

    弹出窗口应警告您授予API执行lambda函数的权限 .


    API方法:

    另外,感谢Richard Downer对此代码的解释:

    资源策略与IAM策略不同,设置IAM策略不起作用 .

    创建Write-AGIntegration后,需要使用Add-LMPermission api调用 .

    这是一个例子:

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

相关问题