【发布时间】:2016-08-20 13:42:31
【问题描述】:
我在 API 网关 (Auth: AWS_IAM) 下设置了 GET 方法,并拥有一个具有开发人员身份的 Cognito 池。我在 get 方法后面有一个 lambda。
当我调用 Cognito 时,我会获得临时凭据并担任角色。我担任的角色具有执行和访问 API 网关上所有内容的适当权限。
...
{
"Effect": "Allow",
"Action": [
"execute-api:Invoke"
],
"Resource": [
"*"
]
},
{
"Effect": "Allow",
"Action": [
"apigateway:GET"
],
"Resource": [
"*"
]
}
...
当我使用此设置调用 API 网关时,我收到 500,内部服务器错误。
如果我从策略中删除上述 API 网关权限,那么我会得到 403 error forbidden (User: arn:aws:sts::xxxxx:assumed-role/Cogn_Auth_Role/xxx is not authorized to perform: execute-api:Invoke on resource: arn:aws:execute-api:us-east-1:xxxx:xxx/xxx/GET/events
如果我将AdminAccess 附加到此角色,那么一切正常。这是怎么回事?我错过了什么吗?
【问题讨论】:
-
嗨,johnny,你成功了吗?
-
是的,请参阅下面的第二个答案。我需要的是 Lambada 调用。试试 AWS 策略模拟器,如果您遇到类似情况,看看您缺少哪些权限。
-
非常感谢@johnny。让我尝试使用 lambda 调用。但我很困惑,我们不能在 cognito 和没有 lambda 的情况下使用 API Gateway?
-
我认为这取决于您的架构方式,但总的来说您应该能够将它们一起使用。
-
此文件策略位于何处?
标签: amazon-web-services aws-lambda aws-api-gateway amazon-cognito amazon-iam