【问题标题】:AWS API Gateway error: API Gateway does not have permission to assume the provided role as S3 proxyAWS API Gateway 错误:API Gateway 无权承担提供的角色作为 S3 代理
【发布时间】:2020-03-31 18:12:01
【问题描述】:

有类似的问题,但他们有我尝试过的答案。 我不确定我可能做错了什么,但我们将不胜感激。

测试详情:

方法执行测试的错误; 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 To 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

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

角色具有信任关系集:

【问题讨论】:

    标签: api amazon-web-services amazon-s3 aws-api-gateway


    【解决方案1】:

    要解决此问题,请转到 IAM 中的角色定义并选择信任关系选项卡。从这里编辑策略并为 Principal Service 添加apigateway.amazonaws.com,如下所示。

    这将授予 API Gateway 除了现有的 Lambda 权限之外,还可以代入角色来运行您的函数。

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

    【讨论】:

    • 非常感谢!阻止我发疯。官方文档再一次没有提到这一点,这对他们来说非常糟糕!
    • 欢迎您@CliveSargeant。很高兴知道它有帮助:)
    • 谢谢@VijayanathViswanathan。很有帮助。
    • 但有问题我看到了具有相同 JSON 的信任关系。
    • @VitalyZdanevich 不同之处(至少对我而言)是在“apigateway.amazonaws.com”周围添加方括号
    猜你喜欢
    • 2019-09-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-12-25
    • 2018-02-13
    • 2018-12-24
    相关资源
    最近更新 更多