带有代理Lambda的AWS API Gatewat:对Lambda函数的权限无效 [英] AWS API Gatewat with proxy Lambda: Invalid permissions on Lambda function

查看:107
本文介绍了带有代理Lambda的AWS API Gatewat:对Lambda函数的权限无效的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当lambda函数的名称作为阶段变量出现时,我将AWS API Gateway与代理Lambda一起使用.意味着我只有一个API集成,可以根据部署的阶段连接到适当的lambda. 请在此处查看总体思路:

I am using AWS API Gateway with a proxy Lambda, when the name of the lambda function is coming as a stage variable. Meaning I have a single API integration which connects to appropriate lambda according to the deployed stage. See the general idea here:

当我测试一个阶段(称为:"staging")时,一切正常,但是当测试另一阶段(生产")时,出现错误由于配置错误,执行失败:对Lambda函数的权限无效"

When I test one of my stages (called: "staging") everything works fine, but when testing the other stage ("production") I get the error "Execution failed due to configuration error: Invalid permissions on Lambda function".

我已经测试并验证的事物:
1.应该通过API调用的两个lambda都可以正常工作,并且在从Lambda仪表板进行测试时可以按预期进行操作.
2.我已确保(多次)已授予API网关调用我的lambda函数的权限(即执行"aws lambda add-permission ...").此后,我已经多次验证了该政策(即执行"aws lambda get-policy ...").

Things I already tested and verified:
1. Both lambdas which should be invoked by the API work well and as expected when tested from the Lambda dashboard.
2. I've made sure (many times) that I've given permission to the API gateway to invoke my lambda function (i.e. executed "aws lambda add-permission..."). I've validated the policy afterwards many times (i.e. executed "aws lambda get-policy...").

您知道我还能检查什么吗?我在这里可能忘记了什么? 谢谢.

Any idea what else I can check ? What I might have forgotten here ? Thanks.

推荐答案

找不到原因,但是找到了解决该问题的解决方法. 我没有使用$ stageVariables作为Lambda函数名称,而是显式地编写了将要一一使用的Lambda函数的名称.这样,AWS会自动向Lambda函数授予权限(对于您显式写入的每个Lambda函数).之后,您可以将集成重新编辑为使用阶段变量.

Couldn't find the reason but found a workaround which solved the problem. Instead of using $stageVariables as the Lambda function name, I explicitly wrote the names of the Lambda function I will be using one by one. This way AWS will give permission to the Lambda functions automatically (for each one u explicitly write). After that you can edit the integration back to using stage variables.

这篇关于带有代理Lambda的AWS API Gatewat:对Lambda函数的权限无效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆