AWS API网关错误:API Gateway没有权限扮演S3代理的提供角色。

60

有类似的问题,但它们的答案我都尝试过了。我不确定我哪里做错了,但任何帮助都将不胜感激。

测试详细信息: enter image description here

来自方法执行测试的错误; PUT请求:

Execution log for request test-request
Mon Oct 16 10:13:47 UTC 2017 : Starting execution for request: test-invoke-request
Mon Oct 16 10:13:47 UTC 2017 : HTTP Method: PUT, Resource Path: /pop-data-xmlz/test.xml
Mon Oct 16 10:13:47 UTC 2017 : Method request path: {item=test.xml, folder=pop-data-xmlz}
Mon Oct 16 10:13:47 UTC 2017 : Method request query string: {}
Mon Oct 16 10:13:47 UTC 2017 : Method request headers: {Content-Type=application/xml}
Mon Oct 16 10:13:47 UTC 2017 : Method request body before transformations: <test>
test string
</test>
Mon Oct 16 10:13:47 UTC 2017 : Request validation succeeded for content type application/json
Mon Oct 16 10:13:47 UTC 2017 : Execution failed due to configuration error: API Gateway does not have permission to assume the provided role
Mon Oct 16 10:13:47 UTC 2017 : Method completed with status: 500

我正在跟随API Gateway到S3教程 (http://docs.aws.amazon.com/apigateway/latest/developerguide/integrating-api-with-aws-services-s3.html),并尝试执行PUT请求。

API Gateway在us-east-1,S3桶在us-east-2。

已创建角色:APIGatewayProxyCustom

附加了一个允许对S3存储桶进行PUT请求的策略(pop-date-ingest)。 enter image description here

该角色设置了信任关系: enter image description here

1个回答

153

要解决这个问题,请进入 IAM 中你的 "角色" 定义并选择 "信任关系" 选项卡。在此处编辑策略并为 "主体服务" 添加 apigateway.amazonaws.com,如下所示。

这将授予 API 网关 执行你的函数的角色扮演权限,除了现有的 Lambda 权限。

{
   "Version": "2012-10-17",
   "Statement": [
      {
        "Effect": "Allow",
        "Principal": {
            "Service": ["apigateway.amazonaws.com","lambda.amazonaws.com"]
        },
        "Action": "sts:AssumeRole"
      }
    ]
}


6
非常感谢!这避免了我变得疯狂。再一次,官方文件没有提及这一点,他们做得很糟糕! - Clive Sargeant
不客气,@CliveSargeant。很高兴知道它有帮助 :) - Vijayanath Viswanathan
谢谢@VijayanathViswanathan。非常有帮助。 - VenVig
5
但是我在问题中看到了与相同JSON相关的信任关系。 - Vitaly Zdanevich
1
@VitalyZdanevich 对我来说,区别在于在服务中添加方括号,即在“apigateway.amazonaws.com”周围添加方括号。 - William Ardila
显示剩余3条评论

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接